Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

0

Yeah

0

ooo, that's enought, thanks

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.