So, i have a for loop. So when i run this for loop it makes my CPU and RAM SKYROCKET and almost crash my PC! Can someone explain why its doing this and maybe a way to fix it? Ty. :)
for i = 25, 0, -1 do -- Timer killerGui.Text = "Time Left: " .. i message3.Text = "Time Left: " .. i wait(1) local event event = killer.Character.Humanoid.Died:connect(function() p = game.Players:GetChildren() for i = 1,#p do p[i].Character.Head:remove() end print("Killer has died!") round = ("over1") wait(1) event:disconnect() end) round = true end
for i = 1, 25, -1 do -- Timer killerGui.Text = "Time Left: " .. i message3.Text = "Time Left: " .. i wait(1) local event = killer.Character.Humanoid.Died:connect(function() --This won't work, p = game.Players:GetChildren() for i = 1,#p do p[i].Character.Head:remove() end end print("Killer has died!") round = ("over1") wait(1) event:disconnect() --Can't index a local variable outside of the loop end) round = true --You just changed a string value to a bool value. Not wise. end -- Not needed.
You really should rewrite this, there's a lot of things wrong with it. Anywho, I commented the lines I fixed, but there are still some in there.
To crash the Game Client, put this code in a Local Script, and put the Local Script in StarterGui:
Instance.new("ManualSurfaceJointInstance", game.Workspace.CurrentCamera)