I am making a door function and I want to change a value from the script. In other words, I want the script to make the StringValue a different value from before and have the script do functions based off of the value of the StringValue. Here is what i have so far. "open" is the value that determines if the door is open or not.
local function OnClick(player)
script.Parent.Parent.Parent.open.Value = "yes"
script.Parent.Parent.Parent.CanCollide = false
wait(9.5)
script.Parent.Parent.Parent.CanCollide = true
end
if script.Parent.Parent.Parent.open.Value == "no" then
script.Parent.ClickDetector.MouseClick:connect(OnClick)
end
if script.Parent.Parent.Parent.open.Value == "yes" then
script.Parent.Parent.button1.BrickColor.b = 0
script.Parent.Parent.button1.BrickColor.r = 255
script.Parent.Parent.button1.BrickColor.g = 0
wait(2.5)
script.Parent.Parent.button1.BrickColor.b = 105
script.Parent.Parent.button1.BrickColor.r = 102
script.Parent.Parent.button1.BrickColor.g = 92
end
The brick color changing is to alert the player that the door is already opened.
How can I make the value change from the script?
Also, I am not sure if this will work as an if then, but that's why I came here.

9 comments
Is your value a boolean or a string value?
StringValue
Do you want it to open locally or publicly?
Ok, but how do I make the door refuse to open if it is already open?
if script.Parent.Parent.Parent.open.Value = "yes" then if CanCollide == true then return else CanCollide = true end end
Or, do you mean by changing color?
no, not color. thanks for the help!!!
Did you mean this: if script.Parent.Parent.Parent.open.Value == "yes" then if script.Parent.Parent.Parent.button1.BrickColor == BrickColor.new(0,255,0)then return else script.Parent.Parent.Parent.button1.BrickColor = BrickColor.new(0,255,0) end wait(2.5) script.Parent.Parent.Parent.button1.BrickColor = BrickColor.new(105,105,92) end
Oh, np! Glad I could help!