InstanceState<T>
A value that is kept separately for each instance and tells you when it changes, which you create with state.create_per_instance.
A value that is kept separately for each instance and tells you when it changes, which you create with state.create_per_instance.
Gives a copy of one instance's value, which still works for 5 seconds after it is destroyed.
print(health:get(door))Use it forchecking how much health a crate has left before deciding whether it breaks.
instanceThe instance.Changes one instance's value, and is an error once that instance is destroyed.
health:set(door, 100)Use it formarking a checkpoint as reached, or setting whether a door is locked.
instanceThe instance.valueThe new value.Hands your function one instance's value, and saves whatever it gives back.
health:update(door, function(value) return value - 10 end)Use it forchanging a tower's upgrade level when its data is stored together as a table.
instanceThe instance.updateGets the value and returns the new one.Adds to one instance's number value, or takes away, and gives back the new value.
health:increment(door, -10)Use it fortaking a bit of health off a wall each time a player hits it.
instanceThe instance.amountoptionalHow much to add, 1 by default. A negative amount takes away.