Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When I click this part why am I not Destroyed?

Asked by 10 years ago
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)

0
Is it outputting anything? TheGuyWithAShortName 673 — 10y

1 answer

Log in to vote
0
Answered by
painzx3 43
10 years ago

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.

Ad

Answer this question