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

How do I make a click detector kill the player?

What is wrong with this script? I want it to kill the player who clicks it. I put this on a script inside of the click detector.

script.Parent.MouseClick:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent:FindFirstChild('Humanoid').Health = 0
	end
end)

2 answers

Im not 100% sure, but i believe hit would be a child of the player, not the character, try script.Parent.MouseClick:Connect(function(hit) 2 if hit.Parent.Character:FindFirstChild('Humanoid') then 3 hit.Parent.Character:FindFirstChild('Humanoid').Health = 0 4 end 5 end)

4 comments

0

Oh well lol

0

https://developer.roblox.com/api-reference/class/ClickDetector MouseClick passes the player when used with ClickDetectors

1

also in the future, try putting your code in code blocks

0

Yeah i just joined the website when i wrote this

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