I am making a game heavily based off of BuildIntoGames', "Guest Defense", and the if statement isn't working so that it can end the wave!
while true do if(game.Workspace.Enemyskilled.Value == 8) then print("Wave 1 finished") randomSong:Stop() script.Voice:Play() player.PlayerGui.Wave1:Remove() end end
In a while true do
loop you must add wait() or else the code will crash causing Studio to crash (possibly)
What I suggest you do is label all the variables;
local randomSong = -- your variable local V = script:WaitForChild('Voice') local plr = game.Players.LocalPlayer
remember you can use the player in local scripts!
If that script is only part of your code then, please add the rest in.
Anyway, the script should look like this if you have all your variables;
local variables -- insert all variables while true do wait(1) if(game.Workspace.Enemyskilled.Value == 8) then print("Wave 1 finished") randomSong:Stop() script.Voice:Play() player.PlayerGui.Wave1:Destroy() -- Do not use :Remove() use :Destroy() end end
If you are able to add all variables and make sure this is a local script and all then your good to go!
Anyway, this is basically a model for you to learn on why your script isn't working.
If you checked through all of those then your code should work
If I helped then please accept answer ;)
Good luck and have fun developing!