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

0

Is your value a boolean or a string value?

0

StringValue

0

Do you want it to open locally or publicly?

0

Ok, but how do I make the door refuse to open if it is already open?

0

if script.Parent.Parent.Parent.open.Value = "yes" then  if CanCollide == true then return else CanCollide = true end end

0

Or, do you mean by changing color?

0

no, not color. thanks for the help!!!

0

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

0

Oh, np! Glad I could help!