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

For loop to check for increased walkspeed doesnt work?

I'm trying to make an AntiCheat system, but nothing happens when I increase my WalkSpeed.

for i, player in pairs(game.Players:GetPlayers()) do
	wait(timeBetweenScans)
	local cheaters = {}
	if outputInfo == true then
		print("Performing a Cheat Scan...")
	end
	if antiSpeed == true then
		if player.Character.Humanoid.WalkSpeed > maxSpeed then
			player:Kick(speedReason)
		end
	end
	if antiJump == true then
		if player.Character.Humanoid.JumpPower > maxJump then
			player:Kick(jumpReason)
		end
	end
	if antiGod == true then
		if player.Character.Humanoid.MaxHealth > maxHealth then
			player:Kick(godReason)
		end
	end
	if outputInfo == true then
		
	end
end

1 comment

0

Unused variable 'cheaters', recommend to remove it

2 answers

Hello there! I believe the current state of your script will only perform at the beginning of the game. What you may want to do is add a while loop before the for loop, so it is checking constantly.

while wait(0.1) do 
	for i, player in pairs(game.Players:GetPlayers()) do
	    local cheaters = {}
	    if outputInfo == true then
		        print("Performing a Cheat Scan...")
		    end
		    if antiSpeed == true then
		        if player.Character.Humanoid.WalkSpeed > maxSpeed then
		            player:Kick(speedReason)
		        end
		    end
		    if antiJump == true then
		        if player.Character.Humanoid.JumpPower > maxJump then
		            player:Kick(jumpReason)
		        end
		    end
		    if antiGod == true then
		        if player.Character.Humanoid.MaxHealth > maxHealth then
		            player:Kick(godReason)
	           end
	           end
		    if outputInfo == true then
	 
	    end
	end
end

Let me know if this works. You can also try using PropertyChangedSignal to see when the humanoid's properties change value. Read more about it here: (http://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal)

Remember, a server script can not see if you are changing walk speed on the client, it will remain the same for the server.

To fix this, change this into a local script, that only checks on the local player. But this comes with a problem, the exploiter can disable the local script.

But the local script can still catch most exploiters if they don not see the local script.

A tip on disguising the local script is by renaming to someting else then "AntiCheat" or "AntiExploit", and do not rename it to like someting wierd or scrambled, because thats suspicious.

Rename it to like "ClientReplicator" or "ClientMethods".

I hope this helps!

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