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

How can i skip the kicked player in a table?

Asked by 3 years ago
Edited 3 years ago

I made a anti-cheat, but whenever a player get kicked the loop break.

run = coroutine.create(function()
    while wait(.1) do
        for i,arunning in pairs(humrunning) do
            plr = game.Players[tostring(arunning)]
            if plr then
                if plr.data.stat.actualsta.Value > 0 then
                    plr.data.stat.rstat.agi.Value += 0.005 * expboost
                    plr.data.stat.rstat.melee.Value += 0.0005 * expboost
                    plr.Character.Humanoid.WalkSpeed = (plr.data.stat.rstat.agi.Value/20) + (plr.data.stat.rstat.melee.Value/50) + (plr.data.stat.rstat.dagger.Value/20) +(plr.data.stat.rstat.magic.Value/50) + 20
                else
                    plr.Character.Humanoid.WalkSpeed = 16
                    plr.data.stat.actualsta.Value = 0
                    plr.data.isrunning.Value = false
                end
            end
        end
    end
end)

(server side script) i dont know how i can fix this. Pls help.

0
Use `FindFirstChild(tostring(arunning))` instead of `[tostring(arunning)]` since indexing will throw an error if player does not exist, also check for plr.Character and plr.Character.Humanoid not being nil, that can also throw an error. imKirda 4491 — 3y
0
If the player leaves or gets kicked from the game, remove their name from the table: it solves your problem and reduces potential memory leaks Rare_tendo 3000 — 3y
0
Ty imKirda. No more errors! Davviidblox 3 — 3y

Answer this question