What do you want to achieve? Keep it simple and clear!
I wanna make it so if the player WalkSpeed change to below or zbove 16 then the player get kicked.
What is the issue? Include screenshots / videos if possible!
I have no errors showed, but it’s do not work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using the plauer model, refer to the workspace and nothing.
game.Players.PlayerAdded:Connect(function(plr)
if plr.Humanoid.WalkSpeed ~= 16 then
plr:Kick()
end
end)
Humanoid isn’t part of player. You could also consider adding a CharacterAdded event to wait for the character to fully load
As @Jackscarlett suggested, GetPropertyChangedSignal is a good way to handle changes like this
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Humanoid:GetPropertyChangedSignal('WalkSpeed'):Connect(function()
if char.Humanoid.WalkSpeed > 16 then
plr:Kick()
end
end)
end)
end)
But keep in mind that exploiters could still bypass this, them changing their walkspeed will not change on the server
Just make it a Server Script, changing it to a Local Script (Even if you have a Anti-Disabled feature) will still make it exposed to hackers/exploiters
And how would you do that? Don’t even trust the client; they can do anything.
Even if this is a server script, if a client changes their walkspeed, it won’t be detected on the server, therefore deeming your whole anti-cheat useless.
Maybe you should post the answer here in another comment? Other people may have this problem so if they stumble upon this post, you should probably describe what you did to fix it.
Also, judging by what this post looks like, the security on your anti-speed exploit is seriously flawed. Even if you have an anti-disable script on the client, they can disable that too. Also, if the anti-disable is on the server, the server won’t even see if the player disabled the script.
You are using the PlayerAdded event which only triggers when a player joins, therefore, their walk speed which of course, will be 16, like many people said, you need to use GetPropertyChangedSignal.
Not really. Just because it is in a crucial script doesn’t mean they can’t edit the script. They can just straight up edit the script to remove the anti-disable. The only good way to do walkspeed checks is on the server by checking their velocity. If it is higher than a certain amount and they aren’t falling or something, kick them.
This won’t work in games that have many parts due to load times. In fact, this script is highly unreliable. Why not just use CharacterAdded? This will also break when they reset or die.
This is the correct way, and it uses .Changed:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").Changed:Connect(function(property)
if property == "Walkspeed" and char.Humanoid.Walkspeed ~= 16 then
plr:Kick()
end
end)
end)
end)