Hello,
I was trying this for over an hour, tried youtube vids, the wiki, and google. Im trying to make a GUI button that kills you when you click it. I have the gui and everything, but I want to know how the script would go.
This is what i was trying:
Button.MouseButton1Down:connect function()
game.Player.Humanoid.Health = 0
end
Im not a great scripter, still learning, but just asking for a little help with this certain script.
Make sure the gui you are working on has the .MouseButton1Down event. (imagebutton, textbutton, etc..) Also in your code you need to access the character from the localplayer.
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
If you wanted to click the gui and have it kill your character, you're better off with the .MouseButton1Click event
Make this a localscript and parent it in the gui object
local player = game:GetService'Players'.LocalPlayer local gui = script.Parent repeat wait() until player.Character local character = player.Character gui.MouseButton1Down:connect(function() local humanoid = character:FindFirstChild'Humanoid' if humanoid then humanoid.Health = 0 end end)