Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I make a decent loop that doesn't glitch?

Asked by 4 days ago

Hello everyone!

I have been trying for ages to make a decent loop function that can play alarms when a BoolValue in workspace is true. This is what I got so far, I tried many things but none of them worked:

local playergui = game.Players.LocalPlayer.PlayerGui

while wait(game.Workspace.Lockdown.Changed or game.Workspace.CB.Changed or game.Workspace.FB.Changed) do
--LOCKDOWN
if game.Workspace.Lockdown.Value == true then
    playergui.ControlPanel.Frame.SiteSituation.Lockdown.TextLabel.Text = "ON"
    playergui.Lockdown:Play()
    playergui.Lockdown.Looped = true
end

if game.Workspace.Lockdown.Value == false then
    playergui.ControlPanel.Frame.SiteSituation.Lockdown.TextLabel.Text = "OFF"
    playergui.Lockdown:Stop()
    playergui.Lockdown.Looped = false
end

Please help.

Answer this question