I wanted to make a door that opens when the value reaches 0.
Also the text that tells when the door is going to open and the status doesn't change!
Help?
local value = script.Parent.Value
is a NumberValue
local value = script.Parent.Value door = script.Parent.Door local text = script.Parent.Parent.Model.Frame.SurfaceGui.Number.Text local statest = script.Parent.Parent.Model.Frame.SurfaceGui.StatTitle.Text while wait(1) do value.Value = value.Value -1 text = "Time:"..value.Value if value.Value >= 1 then door.Transparency = .5 door.CanCollide = false elseif value.Value <= 0 then statest = "Status: Open" value.Value = 10 text = "Time:"..value.Value elseif value.Value <= 0 then door.Transparency = 0 door.CanCollide = true text = "Time:"..value.Value statest = "Status: Close" end end
I'm not sure why the value isn't changing, but there are a couple other issues in this script.
The text isn't changing because you set the variables equal to the strings of text that the each GUI holds instead of making a reference to the GUI and setting the property after words.
local text = script.Parent.Parent.Model.Frame.SurfaceGui.Number local statest = script.Parent.Parent.Model.Frame.SurfaceGui.StatTitle text.Text = "Time: " .. value.Value statest = "Status: Closed"
The second problem is that have two elseif statements that have the exact same parameters. This means that the second on will never function. Instead I used a variable to determine the state of the door.
local open = false if value.Value == 0 then open = not open -- Switch true to false and vice-versa if open then door.Transparency = 0.5 door.CanCollide = false else door.Transparency = 0 door.CanCollide = true end value.Value = 10 end
Full Script
local value = script.Parent.Value local door = script.Parent.Door local text = script.Parent.Parent.Model.Frame.SurfaceGui.Number local statest = script.Parent.Parent.Model.Frame.SurfaceGui.StatTitle local open = false while wait(1) do value.Value = value.Value - 1 text.Text = "Time: "..value.Value if value.Value == 0 then open = not open -- Switch true to false and vice-versa if open then door.Transparency = 0.5 door.CanCollide = false else door.Transparency = 0 door.CanCollide = true end value.Value = 10 end end