I am making a script that kicks people when there walkspeed exceeds a certain limit. Why isn't this working? The script is under StarterCharactarScripts in StarterPlayer
plr = script.Parent.Name if script.Parent.Humanoid.Changed:connect()then if script.Parent.Humanoid.WalkSpeed > 22 then game.Players.plr:Destroy() end end
plr = script.Parent.Name if script.Parent.Humanoid.Changed:connect()then if script.Parent.Humanoid.WalkSpeed > 22 then game.Players[plr]:Kick("Please do not Exploit.") -- you can place a variable under "[]" otherwise it will just say "plr" is nil, because there is no literal "plr" object in the Players Service. end end
You should put a script in ServerScriptService that utilizes game.Players.PlayerAdded and Player.CharacterAdded.
Here is an example:
local MAX_SPEED = 22 game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoid = character:FindFirstChildOfClass('Humanoid') humanoid.Running:Connect(function(speed) if speed > MAX_SPEED then player:Kick('Please do not exploit!') end end) end) end)
Now this code is the best, but hopefully it helps.