Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I need help making a script for kicking people when they exploit. Can anyone help?

Asked by
iWagen 5
6 years ago

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
0
Try game.Players:FindFirstChild(plr):Destroy() LawlR 182 — 6y
1
you mean :Kick() not :Destroy() User#23365 30 — 6y
0
True. :Kick() Is better and allows you to leave a message. piRadians 297 — 6y
View all comments (2 more)
0
kick() remove() disconnect() greatneil80 2647 — 6y
0
I don't recommend this but, use Remote Events and access a script in the replicated storage. Or simply use a Local Script... Probably your error. B_rnz 171 — 6y

2 answers

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
6 years ago
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
0
still the script can be accessed and deleted by the exploiter User#23365 30 — 6y
Ad
Log in to vote
0
Answered by
Optikk 499 Donator Moderation Voter
6 years ago

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.

0
If an exploiter changes walkspeed locally, I don't think it will replicate to the server. User#22604 1 — 6y

Answer this question