I have this script that test if the Gui is on or off (Open or Closed)
The problem is probably the for i in pairs(Numbers) do
Script:
local Box = script.Parent.Main local Open = script.Parent.Button.IsOpen if Open == false then script.Parent.Button.BackgroundColor3.r = 94 script.Parent.Button.BackgroundColor3.g = 211 script.Parent.Button.BackgroundColor3.b = 4 for i in pairs(0,-220,0.3,0) do -- "1" Box.Position.X.Offset(i) end else script.Parent.Button.BackgroundColor3.r = 211 -- It starts saying that the problem is here. So the script could actually be stopped from "1" script.Parent.Button.BackgroundColor3.g = 25 script.Parent.Button.BackgroundColor3.b = 0 for i in pairs(0,0,0.3,0) do -- "2" Box.Position.X.Offset(i) end end
Problem
So the possible problems I see with your script is checking if an Instance is true instead of checking if a value is true and checking it only ONCE. Also, it might be possible that you used the RGB coloring wrong.
Solution
So first of all, we will need to add .Value
to your IsOpen and add a variable for the actual instance instead of the value.
Result:
local Open = script.Parent.Button.IsOpen.Value local OpenInstance = script.Parent.Button.IsOpen -- we will need this value for something
Alright, your script still doesn't work?
You'll need to add the Changed
event. It fires everytime the value changes. (wiki)
The result would be this: (I fixed the RGB.)
local Box = script.Parent.Main local Open = script.Parent.Button.IsOpen.Value local OpenInstance = script.Parent.Button.IsOpen if Open == false then script.Parent.Button.BackgroundColor3 = Color3.fromRGB(94, 211, 4) for i in pairs(0,-220,0.3,0) do -- "1" Box.Position.X.Offset(i) end else script.Parent.Button.BackgroundColor3 = Color3.fromRGB(211, 25, 0) for i in pairs(0,0,0.3,0) do -- "2" Box.Position.X.Offset(i) end end
Note, I did not check the script so make sure to comment or ping me in the chat if something happens.