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

(Closed) How can i change a value from a script?

Asked by
Stycon 30
6 years ago
Edited 6 years ago

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.

0
Is your value a boolean or a string value? mixgingengerina10 223 — 6y
0
StringValue Stycon 30 — 6y
0
Do you want it to open locally or publicly? mixgingengerina10 223 — 6y
0
Ok, but how do I make the door refuse to open if it is already open? Stycon 30 — 6y
View all comments (5 more)
0
if script.Parent.Parent.Parent.open.Value = "yes" then  if CanCollide == true then return else CanCollide = true end end mixgingengerina10 223 — 6y
0
Or, do you mean by changing color? mixgingengerina10 223 — 6y
0
no, not color. thanks for the help!!! Stycon 30 — 6y
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 mixgingengerina10 223 — 6y
0
Oh, np! Glad I could help! mixgingengerina10 223 — 6y

Answer this question