So basically I wanted to make a script for a button(or more accurately, clickable part/brick) that kills the player whenever they click on it. However, my script doesn't work at all, and it doesn't seem to be showing any errors or warnings. I can still click on the button though, it just doesn't do anything.
This is the script:
local deathbutton = game.Workspace.DeathButton -- declares local variable for deathbutton(button that will kill player on click)
deathbutton.ClickDetector.MouseClick:Connect(function(plr) -- Connects click event to the function
if plr:FindFirstChild("Humanoid") then -- checks if humanoid exists in player
plr.Health = 0 -- if so, player's health is set to 0
end
end)
I'm fairly new to scripting, so if anybody could point out the mistake in my code, I'd be grateful

1 comment
Humanoids are not in the player, they are in the character lol