Last question: When the string Value Changes from "empty" to "water" as said in this script: How does the state best be handled,? Or How would I set the state as a function?
script.Parent.Handle.Touched:connect(function(touchedpart)
01 | local state = touchedpart:FindFirstChild( "State" ) |
02 | if ( state ~ = nil ) then |
03 | -- door has a state, so it is either open or closed |
04 | if ( state.Value = = "empty" ) then |
05 | -- set the door's state to "open" |
06 | state.Value = "water" |
07 | -- actually move the door/destroy the door so it opens aka perform the action |
08 | -- for example: touchedpart:Destroy() |
09 | -- destroy the key |
10 | script.Parent:Destroy() |
11 | end |
12 | end |
13 | end ) |
Here is my current Function Handling:
1 | function StateChange 4 () |
2 | script.Parent.State.Value = "water" |
3 | Fluid.Transparency = 0 |
4 | end |
The "State" is a StringValue class object whose Parent is Door; aka, it's a "real" object
Therefore;
1 | local StateChange 4 = function () |
2 | game.Workspace.Door.State.Value = "water" |
3 | Fluid.Transparency = 0 |
4 | -- other stuff to do |
5 | end |