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

How can i make a killing button with clickdetector?

I want to make the button kill player that clicks it

This is what i have so far and it isnt working (new to lua):

local clickDetector = workspace.Part.ClickDetector local player = game.Players.LocalPlayer

function onMouseClick() player.Health = 0 end

clickDetector.MouseClick:connect(onMouseClick)

2 comments

0

Is it a local script?

0

yes

3 answers

This is a server script, put into the click detector or part.

local clickDetector = script.Parent -- or the click detector in part.
clickDetector.MouseClick:Connect(function(plr) -- the click detector automatically gets the player 
	local player = plr.Character.Humanoid -- get character humanoid
	player.Health = 0
end)

So first make a part, and inside of it, make a click detector. Inside of the clickdetector, put this (normal script):

script.Parent.MouseClick:Connect(function(player)
	player.Character.Humanoid.Health = 0
end)

That should do it. This should kill the player who clicked the part.

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