Firstly, you should learn how to tab it correctly. It will greatly help your scripting. An example would be this:
while true do
c = script.Parent.LightUp:GetChildren()
if script.Parent.ON.Value == true then
for i = 1, #c do
if math.random() > 0.5 then
c[i].BillboardGui.ImageLabel.Visible = true
else
c[i].BillboardGui.ImageLabel.Visible = false
end
end
elseif script.Parent.ON.Value == false then
wait(.1)
end
end
Next off is how to do this correctly. As of right now, "while true do" is basically a loop that will continue on forever. This is because the "while" loop checks if the condition is true or not. "While true" is a means of repeating the script over and over without it stopping, thus nothing will happen after it. This will NOT check boolean values. However, you can still use the "while" loop. Only with a bit of editing. Instead of checking if true is possible, you can check if the variable is true or not.
while script.Parent.ON.Value == true do
What this will do is check if the value of the boolean value that you have under your script parent. In order to compensate and correct this entire script, you would remove the if's and elseif's that deal with the on value. Thus delete lines 3, 11, 12, and 13. With this being the end result:
while script.Parent.ON.Value == true do
c = script.Parent.LightUp:GetChildren()
for i = 1, #c do
if math.random() > 0.5 then
c[i].BillboardGui.ImageLabel.Visible = true
else
c[i].BillboardGui.ImageLabel.Visible = false
end
end
end
Shame on you for skipping to the end if you did so, because this post will help your scripting knowledge as will as help you find your answer!
5 comments
"script.Parent.ON.Value == true" is kind of redundant.. since "script.Parent.ON.Value" should return true anyways.
Idk but, That didn't work. Currently it isn't giving an errors, So I can't really trobleshoot it.
Would putting a wait in the while loop work?
Try putting a print function in somewhere for the code (ie. Print after line 7). If it doesn't show tell me and what line you put it afterwards.
Nothing came up, So I think that'd be the while loop