ServerSided Anti-Cheat

Hello, So For today, im trying to make a Simple Anti-Cheat that See the Players WalkSpeed and Kicks them if its more than 20

So the Code im using is

game.Players.PlayerAdded:Connect(function(plr)
	local Char = plr.CharacterAdded
local Humanoid =	Char:FindFirstChild("Humanoid")
	if Humanoid.WalkSpeed > 20 then
		plr:Kick('Speed Hacking')
		
	end
end)

So the Error i get in the Output is “FindFirstChild is not a valid member of RBXScriptSignal”

So from What I See i think it saying the Part where i write

Char:FindFirstChild("humanoid") -- i think This Is Wrong

The Solution I think of trying is

Char:FindFirstChildOfClass("Humanoid")

Do You Think This Can Work?

1 Like

Char:FindFirstChild(“humanoid”)
should be
Char:FindFirstChild(“Humanoid”)
and use local scripts because server side cant kick players

What that error means is that you are trying to find an instance inside of a Roblox function, or at least to my understanding.

So to fix the error, we just make the variable an instance!

if not plr.Character then
 plr.CharacterAdded:Wait()
end
local c = plr.Character

True, But in the Actual script its Pronounced Humanoid

Im Confused, on where i should write that, Do i put it in the function?

You would have to replace that with the line that defines your character:


game.Players.PlayerAdded:Connect(function(plr)
	
	if not plr.Character then
 		plr.CharacterAdded:Wait()
	end

	local Char = plr.Character

	local Humanoid = Char:FindFirstChild("Humanoid")
	if Humanoid.WalkSpeed > 20 then
		plr:Kick('Speed Hacking')	
	end
end)

So i rewrite My Code as,

game.Players.PlayerAdded:Connect(function(plr)
	if not plr.Character then
 		plr.CharacterAdded:Wait()
	end

local c = plr.Character
	local Humanoid =	c:FindFirstChild("Humanoid")
	if Humanoid.WalkSpeed > 20 then
		plr:Kick('Speed Hacking')
		
		
		
		
	end
end)

Yes that would work, but you should probably use the indented code

There is really no point in trying to check the WalkSpeed value of the humanoid on the server, because exploits change the walkspeed on the client, which does NOT replicate to the server

1 Like

yes, but their is no hurt into trying to stop speed hacking.

My point is it does NOTHING to stop speed hacks. The server will show the WalkSpeed as 16, even if exploits change it to something else on the client.

1 Like

yes he should add Humanoid.Running Event

there is things to stop speed hacks, such as checking the moved magnitude every second and comparing it to the last time it was checked, or checking if the walkspeed is changed on the client and firing a remote event to see if it is the same on the server or not.

1 Like

So what if he made an anti-cheat on a local script as well? I’ve heard that local scripts can be edited, but I’ve also heard otherwise

Well, i Could Have a PlayerScript, to Send The Player’s Walkspeed to the server

1 Like

game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local hum = c.Humanoid
hum.Running:Connect(function(speed)
if speed > 20 then
print(“Player is hacking”)
end
end)
end)
end)

try using this!

and if the player’s walkspeed Doesn’t Match what the Server’s Allow i can therefor Kick the Player, and Continue the game.

1 Like

Mk this should work…

game.Players.PlayerAdded:Connect(function(plr)
	local Char = game.Workspace:WaitForChild(plr.Name)
local Humanoid = Char:FindFirstChild("Humanoid")
	if Humanoid.WalkSpeed > 20 then
		plr:Kick('Speed Hacking')
		
	end
end)

quick question , im new at devforum. how to use lua code blocks?

use 3 `of these to do a code block.

1 Like