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)
This video answers that
https://www.youtube.com/watch?v=yJglWQM0h5A
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)
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.