As I said in the comments, that is a For Loop not a While Loop
Loop Resource
To do this, you would use a While Loop, but also doing a Boolean Check.
Something like this, I would assume.
while wait() do
if script.Parent.TopBar.Visible == true then
script.Parent.ImageButton.Visible = true
script.Parent.Forest.Visible = true
script.Parent.Votes.Visible = true
else
script.Parent.ImageButton.Visible = false
script.Parent.Forest.Visible = false
script.Parent.Votes.Visible = false
end
end
You would put this in a LocalScript inside of Intermission ScreenGui.
This will loop through the code every 0.03 seconds, checking if TopBar is visible. If TopBar is visible, it will make those 3 other elements visible as well. If it's not visible, then it will not have those 3 other elements visible.
To do your method, you would put a ServerScript in ServerScriptService and write this.
for _,player in pairs(game:GetService("Players"):GetChildren()) do
while wait() do
if player:WaitForChild("Intermission").TopBar.Visible == true then
script.Parent.ImageButton.Visible = true
script.Parent.Forest.Visible = true
script.Parent.Votes.Visible = true
else
script.Parent.ImageButton.Visible = false
script.Parent.Forest.Visible = false
script.Parent.Votes.Visible = false
end
end
end
Either way really works. Both are efficient, I think?
Another way to do this is
script.Parent.TopBar:GetPropertyChangedSignal("Visible"):Connect(function(value)
But, this way would be easier as it's an always active loop. Refer to the Loop Resource for more information on loops.
Hope this helped! If this worked, let me know by selecting this as an answer!
2 comments
This is not a While Loop, this is a For Loop.
accidentally posted wrong thing, fixed it