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

How to kick a player when a part is clicked?

Hello, im trying to make a ClickDetector that kicks a player when it's clicked, and i need some help with the code, may this one work?

clickd = game.Workspace.note.ClickDetector

clickd.MouseClick:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	plr:kick("")
end)

1 answer

A click detector has the parameter of the person who clicked it. So pretty simple solution here.

local clickd = game.Workspace.note.ClickDetector

clickd.MouseClick:Connect(function(PlayerWhoClicked)
    PlayerWhoClicked:Kick("Kick Message")
end)

Here's what Roblox has to say about ClickDetectors https://developer.roblox.com/en-us/api-reference/class/ClickDetector

Also, Kick is with a capital K.

6 comments

0

upvoted

0

Alright!! Thanks my guy.

0

Don't forget to accept the answer if it worked :)

0

How :v

0

There is a Accept Answer button at the bottom of the post.

0

Ah, i can't see it.

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