Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

a button that kills the player when pressed?

hey. i'm trying to make a button in a GUI where, when you press it, your character dies. i've tried this but it doesn't seem to work. this is under the button, so that the button is the parent of the button. any help?

function parentPressed(player)
	player.Character.Humanoid.Health = 0
end

script.Parent.MouseButton1Down:connect(parentPressed)

1 comment

0

Is this a local or server script?

1 answer

✓ Accepted answer

You almost got it. GuiButton.MouseButton1Down doesn't return a player so you're going to have to define player as a local variable.

Delete "player" in the parentheses on line 1 and add this above the function:

local player = game.Players.LocalPlayer

This discussion is preserved as it was. New answers, comments, and votes are closed.