StateMachine
The StateMachine is a #ModuleScript located in #StarterCharacterScripts where given values are shared between the client and server if set to do so. Certain values are not replicated from client to server for safety reasons.
It works like this:
A #state is defined with the "CreateState" function, which returns a table with elements for that #state
For example;
module.States = {
Running = CreateState(true, false)
}
The first parameter defines the default value of the state. The second defines if the client will replicate to the server.
The StateMachine also has a few functions.
With
StateMachine:SetState(state:string, value:any)
you can set a state. You can technically also manually set the state, but using this function it will automatically fire the .Changed event.
You also have a way to get states, which isn't much different from just getting it within module.States. It will later be used to get stuff from the server on the client.
StateMachine:GetState(state:string)