Question About Walkspeed Changed

Hello! I’m trying to make a anti-cheat, but I’m not sure why this isn’t working. Help? (Code below.) I’m not sure what to change.

Code:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	player.Character:WaitForChild("Humanoid")
	player.Character.Humanoid.WalkSpeed.Changed:Connect(function(player)
		if player.Character.Humanoid.WalkSpeed >= 33 then
			player:Kick("Kicked \nYour account has been kicked from this experience for cheats, exploits, or other reasons. \n \nWas this a mistake? Don't worry, it's just a kick. We will look into this later and determine if you were hacking. \n \nThis kick was given by the anti-cheat of this experience. Roblox, or Roblox Support cannot do anything in this circumstance.")
		end
	end)
end)

Error:

ServerScriptService.Main.Anti-Cheat:4: attempt to index number with 'Changed'
2 Likes

I’d like to point out, whether the Changed event worked or not, that this would be an ineffective anti-cheat. Exploiters modify things to the client, and they don’t replicate to the server.

Now, the problem with the code is that you’re indexing a number (Humanoid.WalkSpeed) with Changed (which is an event for Instances). If you’re trying to get when the WalkSpeed property changes, you should use Humanoid:GetPropertyChangedSignal(“WalkSpeed”):Connect().

4 Likes