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

How can i make a killing button with clickdetector?

Asked by 4 years ago

I want to make the button kill player that clicks it

This is what i have so far and it isnt working (new to lua):

local clickDetector = workspace.Part.ClickDetector local player = game.Players.LocalPlayer

function onMouseClick() player.Health = 0 end

clickDetector.MouseClick:connect(onMouseClick)

0
Is it a local script? imagoodlolboyeee 30 — 4y
0
yes gryuzuz 0 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

This video answers that

https://www.youtube.com/watch?v=yJglWQM0h5A

Ad
Log in to vote
0
Answered by 4 years ago

This is a server script, put into the click detector or part.

local clickDetector = script.Parent -- or the click detector in part.
clickDetector.MouseClick:Connect(function(plr) -- the click detector automatically gets the player 
    local player = plr.Character.Humanoid -- get character humanoid
    player.Health = 0
end)

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
4 years ago

So first make a part, and inside of it, make a click detector. Inside of the clickdetector, put this (normal script):

script.Parent.MouseClick:Connect(function(player)
    player.Character.Humanoid.Health = 0
end)

That should do it. This should kill the player who clicked the part.

Answer this question