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

When I click this part why am I not Destroyed?

local Target = script.Parent 
function onClick(Brick)
	local Player = Brick.Parent:findFirstChild("Humanoid")
	if (Player ~= nil) then
		Player.Health = Player.Health - 100
	end
end
Target.ClickDetector.MouseClick:connect(onClick)

1 comment

0

Is it outputting anything?

1 answer

Use this instead.

local Target = script.Parent
function onClick(Brick)
local h = Brick.Parent:findFirstChild("Humanoid")
if(h~=nil)then
h.Health = 0
end
end
Target.ClickDetector.MouseClick:connect(onClick)

Hex's code had a minor error, he used "FindFirstChild" instead of "findFirstChild" and also you can change the local"h" to whatever you desire.

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