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 6 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)

    local state = touchedpart:FindFirstChild("State")
    if( state ~= nil )then
        -- door has a state, so it is either open or closed
        if( state.Value == "empty" )then
            -- set the door's state to "open"
            state.Value = "water"
            -- actually move the door/destroy the door so it opens aka perform the action
            -- for example: touchedpart:Destroy()
            -- destroy the key
            script.Parent:Destroy()
        end
    end
end)

Here is my current Function Handling:

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

1 answer

Log in to vote
0
Answered by 6 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;

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

Answer this question