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 3 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 — 3y
0
yes gryuzuz 0 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago

This video answers that

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

Ad
Log in to vote
0
Answered by 3 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
3 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