Now I do understand the the error is a way for Roblox to stop long running scripts, but what I don't understand is what in my script is causing it and how can I fix it?
--The purpose of the script is to play music while a main menu is on. --The Boolean in ReplicatedStorage is to let the script know if the MainMenu is on or off --I could have used the Visible property itself but I thought it would be more cleaner to use that. local Menu = script.MenuMusic local MenuBool = false local Lobby = script.LobbyMusic local LobbyBool = false while true do if game.ReplicatedStorage.StartMenu == true and MenuBool == false then Menu:Play() MenuBool = true elseif game.ReplicatedStorage.StartMenu == false and LobbyBool == false then Menu:Stop() Lobby:Play() LobbyBool = true end end
You should'nt use a while loop.
Use a .Changed event instead
game.ReplicatedStorage.StartMenu.Changed
Also on line 10 and 13 you should'nt do an if statement on a object, do it on the value instead
if game.ReplicatedStorage.StartMenu.Value == true then --Code end