Help My Scrip Do Not Kicking Player

Clientsided anti-exploits can be bypassed, exploiters use metatables to make the client think that the WalkSpeed is set to 16 (default walkspeed) and sometimes bypass kicks if it was done on the client.

But the reason is because your script is only checking for the walkspeed when the script starts to run.
Use a Instance.GetPropertyChangedSignal or Instance.Changed event to fix this.

2 Likes

You can’t kick a player on the client due to FilteringEnabled. You have to fire a remote event to the server and then pick it up there and kick the user from there. Also, you should probably say :Kick() instead of :kick().

2 Likes

https://developer.roblox.com/en-us/api-reference/function/Player/Kick

When used from a LocalScript , only the local player’s client can be kicked.

It definitely works but specifies that the client can’t kick other clients.

4 Likes

Like all the replies below, this would be useless against cheaters.
They can easily bypass this by deleting the script or something else.

Here’s an example, you can make a server script instead that checks the player’s HumanoidRootPart’s position every few seconds or frames.
If the position is too far from the previous position, then kick them.

2 Likes

That is False, I have many times made a server side “player kick” for an anti-cheat system.

You can clearly see its a local script, because of "LocalPlayer".

1 Like

Try this:

game.Players.PlayerAdded:Connect(function(player)
  while wait() do
      if player.Character.Humanoid.WalkSpeed ~= 16 then
         player:kick()
     end
  end
end)

Put this in a server side script. (while this works, its not effective against modern-day exploits)

1 Like
  • You should probably use GetPropertyChangedSignal or Changed instead of using a while wait() loop

  • The character may not load right away use CharacterAdded

  • Changes from the client don’t replicate to the server (for example if a exploiter changes their walkspeed to 100 then the server cant see that)


3 Likes

This wouldn’t work. If the client changes their walkspeed it won’t replicate to the server. You’re also polling for no reason, there’s an event for this!

1 Like

I would put it in a loop so it checks the players walkspeed every 3 seconds.

while wait(3) do
if game.Player.LocalPlayer.Character.Humanoid.WalkSpeed > 16 Then
    game.Player.LocalPlayer:Kick()
end
end
2 Likes

Doing this is effectively useless, all an exploiter has to do is type one command and the Local Script is deleted. You should aim to do this on the server, not the client. You can achieve this my doing magnitude checks. You can refer to these posts:

1 Like

There’s no such thing as game.Player, it’s game.Players.

2 Likes

This is just as bad. The best solution for anti-walkspeed exploits is checking the player’s position on the server end, and comparing it to an older position.

This is just showing him an example

1 Like

Here’s a method I use in pretty much all of my games. Put this in a server script.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        char:WaitForChild('Humanoid').Running:Connect(function(speed)
            if speed > 20 then 
                player:Kick("Exploiting") 
            end
        end) 
    end)
end)
1 Like
if game.Player.LocalPlayer.Character.Humanoid.WalkSpeed ~= 16 Then
    game.Player.LocalPlayer:Kick()
end
1 Like

That is false, Roblox gives all character control to the client and sends the character position to the server.

1 Like

Again, that’s false, the one thing that Roblox allows players to have complete control over is there “character” movement, which does replicate to the server.

1 Like

no. the character is owned by the player so if the player has high ping it could cause their speed to change in slow but big intervals that normaly wouldnt be possible.

1 Like

You’re using game.Player…
The service is called ‘Players’. You can access it via game:GetService(“Players”) or game.Players.

(Unrelated to the problem) While I do believe :kick() still works, :Kick() is kind of what Roblox intends to be used universally. It’s kind of like how you can use :connect, but :Connect is the standard.

So here’s a quick fix to get my point across a bit better.

--[[
if game.Player.LocalPlayer.Character.Humanoid.WalkSpeed ~= 16 then
    game.Player.LocalPlayer:Kick()
end
]]--

local Player = game:GetService'Players'.LocalPlayer; -- Notice "Players", not "Player".
if (Player.Character.Humanoid.WalkSpeed ~= 16) then
    Player:Kick() -- Uppercase Kick is the standard.
end

Hope this helps.

1 Like

I hope you find my code useful, it isn’t very reliable for you to depend on the client to check the player’s walk speed. Instead; consider checking the magnitude at which the player is moving at (real-time walking speed).

-- Server scripts should be used more often as a method to patching exploits.
local Players = game:GetService("Players")
local FindFirstChildWhichIsA = game["FindFirstChildWhichIsA"]
local WaitForChild = game["WaitForChild"]

local OnCharacterAdded; OnCharacterAdded = function(Character)
	local Humanoid =
		FindFirstChildWhichIsA(Character, "Humanoid")
		WaitForChild(Character, "Humanoid")
	local RootPart = Humanoid.RootPart or WaitForChild(Character, "HumanoidRootPart")
	local RBXScriptConnection; RBXScriptConnection = Humanoid.StateChanged:Connect(function(LastState, CurrentState)
		if CurrentState == Enum.HumanoidStateType.Running then
			local MovementSpeed = (RootPart.AssemblyLinearVelocity * Vector3.new(1, 0, 1)).Magnitude
			if MovementSpeed >= 80 then
				-- Potentially cheating?
				-- This could be faulty, so I would recommend only checking for absurd numbers.
				return RBXScriptConnection.Disconnect(RBXScriptConnection)
			end
		end
	end)
end

local OnPlayerAdded; OnPlayerAdded = function(Player)
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Edit: Humanoids do take a brief moment to accelerate, so it wouldn’t be a biggie to give a shot at lower numbers.

1 Like