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 11 years ago
1local Target = script.Parent
2function onClick(Brick)
3    local Player = Brick.Parent:findFirstChild("Humanoid")
4    if (Player ~= nil) then
5        Player.Health = Player.Health - 100
6    end
7end
8Target.ClickDetector.MouseClick:connect(onClick)
0
Is it outputting anything? TheGuyWithAShortName 673 — 11y

1 answer

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

Use this instead.

1local Target = script.Parent
2function onClick(Brick)
3local h = Brick.Parent:findFirstChild("Humanoid")
4if(h~=nil)then
5h.Health = 0
6end
7end
8Target.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