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

How can I create a block that kicks people who touch it?

Well I've already asked this a while ago somewhere else, but I still don't really have an answer that worked. I know it's probably pretty simple, but if anyone can help me with this, I'd appreciate it.

1 comment

0

Use a touch event. Make an attempt if you need help. This isn't a site where you ask for scripts.

2 answers

✓ Accepted answer

Zottorus, just use the :Kick() method like this:

script.Parent.Touched:Connect(function(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) and hit.Parent:IsA("Model") then
		game.Players[hit.Parent.Name]:Kick("HAHAHAHAHA")
	end
end)

2 comments

0

I do not recommend that method since if an accessory touched the part it will not return the character's name.

0

i changed it so it cant mess up with accessories

local part = script.Parent --locate yours by your own

part.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") --getting the humanoid local char = hum.Parent --getting the character local plr = game.Players:GetPlayerFromCharacter(char) --getting the player from the cahracter wait() if plr then plr:Kick("insert reason of kick here") --kicking the player end end)

2 comments

0

anything with a humanoid can get kicked and you didnt put a end

0

^ :GetPlayerFromCharacter(char) gets the player from the character, if there isn't a player it will return nil. I modified the script and added an if just to make sure there is a player.

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