Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For Loop CRASHES PC?

Asked by 10 years ago

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

2 answers

Log in to vote
0
Answered by 10 years ago
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.

0
What are the other errors? Also, the other "End" is to end the function it was originally within. RobloxHelper49 55 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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)

Answer this question