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

How do I make it, so when I click a part, it kills the player who clicked it?

Asked by 4 years ago

I tried using a simple kill brick script, but instead of touching it, I tried to make it so that the kill-code triggers when the player clicks it. I basically tried to make the start event comply with the ClickDetector.

script.Parent:mouseClick1(function(kill)
    local human = kill.Parent:findFirstChild("Humanoid")
    if human then
        human.Health = 0
    end
end)
-- I added ClickDetector to the parent of this script.

1 answer

Log in to vote
1
Answered by 4 years ago

Your problem here is you're using the wrong terms, 'mouseClick1' won't work,

Instead, change line 1 to this:

script.Parent:MouseButton1Click:Connect(function(kill)
0
Thanks, ryanaskew!!! This could work with sooo many things relating to clicking stuff!!! (This is not sarcasm. I actually owe you a thanks to this, dude) ABCyahia 24 — 4y
Ad

Answer this question