Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Interaction States (Final Question for now)?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.