Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

6 comments

0

Try game.Players:FindFirstChild(plr):Destroy()

1

you mean :Kick() not :Destroy()

0

True. :Kick() Is better and allows you to leave a message.

0

kick() remove() disconnect()

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.

2 answers

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

1 comment

0

still the script can be accessed and deleted by the exploiter

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.

1 comment

0

If an exploiter changes walkspeed locally, I don't think it will replicate to the server.

This discussion is preserved as it was. New answers, comments, and votes are closed.