Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Interaction States (Final Question for now)?

Asked by 7 years ago

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
13end)

Here is my current Function Handling:

1function StateChange4()
2script.Parent.State.Value = "water"
3Fluid.Transparency = 0
4end

1 answer

Log in to vote
0
Answered by 7 years ago

The "State" is a StringValue class object whose Parent is Door; aka, it's a "real" object

https://imgur.com/a/aaZcD

Therefore;

1local StateChange4 = function()
2    game.Workspace.Door.State.Value = "water"
3    Fluid.Transparency = 0
4    -- other stuff to do
5end
Ad

Answer this question