Help My Scrip Do Not Kicking Player

Hello there!

this script don`t work

while true do
    if game.Player.LocalPlayer.Character.Humanoid.WalkSpeed ~= 16 Then
           game.Player.LocalPlayer:kick()
    end
end
3 Likes

well it wont kick if the user’s speed is 16. also that you should put that in a while wait() loop so it constantly checks.

3 Likes

also the character may not exist so you may want to put this into a startercharacterscript.

4 Likes

It won’t work if its a normal script it has to be local, What kind is it?

4 Likes

put local script in startercharacter script. put this code in:

local char = script.Parent

char:WaitForChild("Humanoid").Changed:Connect(function()
	if char.Humanoid.WalkSpeed ~= 16 then
		game.Players.LocalPlayer:Kick("not today kid")
	end
end)
5 Likes

This would only check the player’s walkspeed once :point_up_2:

This is will constantly check if the player’s walkspeed is not 16:

repeat wait(1) until game:IsLoaded() -- waits until the game is loaded

while wait() do -- constantly checks if the player's walkspeed is not 16
    if game.Player.LocalPlayer.Character.Humanoid.WalkSpeed ~= 16 Then
        game.Player.LocalPlayer:kick()
    end
end
6 Likes

If this is a client-based anti-cheat, do not use this. Exploiters can easily bypass it.

Anyways, you made it only fire once, so putting it into a .Changed function or in a loop might solve your problem.

5 Likes

It should stop about 90% of exploiters though it’s true that they shouldn’t depend on only having a client based anti exploit.

4 Likes

Client-side anti-exploits are pretty much useless. If an exploiter is interested in your game, it will be bypassed easily. I don’t think you can kick the LocalPlayer from a LocalScript either.

You should use a server-sided anti-exploit. If you are not very experienced yet, don’t focus to much on creating an anti-exploit. In my opinion, anti-exploits like speed, flying, flinging, etc. should be done when your game is release-ready and they should be adapted to your game.

This doesn’t apply to anything else! Never trust the client. Especially not with RemoteEvents.

Good luck on your project

3 Likes

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