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

Not killing player that clicks Gui?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I know how to get the parents but its not killing a player when they click on that ImageButton

function Clicked(hit)

    local hum = hit.Parent:FindFirstChild("Humanoid")

    if hum then
        hum.Health = 0
    end
end

script.Parent.MouseButton1Down:connect(Clicked)

1 answer

Log in to vote
2
Answered by
NotSoNorm 777 Moderation Voter
8 years ago

There isn't a hit for a gui! This needs to be a local script

script.Parent.MouseButton1Down:connect(function() --easier to define it here
    local hum = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
     if hum then --if humanoid is there then
        hum.Health = 0
    end
end)


Ad

Answer this question