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

My script is crashing me every time when I run it, even it has wait(1), why?

Asked by
0msh 333 Moderation Voter
7 years ago

My anti-speed exploit is crashing me every time when I test it out and I have no idea why...

wait(1)
local WalkspeedHackPrevent = true
local WalkspeedMax = tonumber("18")
local Plr = game.Players.LocalPlayer
        local Char do
            repeat wait(1) until Plr.Character ~= nil
            Char = Plr.Character
        end
        local Hum do
            repeat wait(1) until Char:FindFirstChild("Humanoid")
            Hum = Char.Humanoid
        end
while true do       
        if WalkspeedHackPrevent then
            if Hum.WalkSpeed > WalkspeedMax then
                    Plr:Kick("Exploiter detected in the server")
end
end
end

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Replace "while true do" with "while wait() do" on line 13.

I can't really explain correctly why, someone else may be able to, but this should prevent it from crashing.

0
Yeah hiimgoodpack 2009 — 7y
0
ooo, that's enought, thanks 0msh 333 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

The last while loop does not have a wait(1). Also you should use WaitForChild() instead:

wait(1)
local WalkspeedHackPrevent = true
local WalkspeedMax = 18
local Plr = game.Players.LocalPlayer
local Char do
repeat wait(1) until Plr.Character ~= nil
    Char = Plr.Character
end
local Hum = Char:WaitForChild("Humanoid")
while wait() do   
    if WalkspeedHackPrevent then
        if Hum.WalkSpeed > WalkspeedMax then
            Plr:Kick("Exploiter detected in the server")
        end
    end
end

But since this is local, hackers might remove this script. You might want to have a server script do this. Sorry if this confuses you.

Answer this question