Im trying to make a button that will kill the player that clicks it, this is what i've got:
script.Parent.MouseClick:Connect(function(click) click.Parent.Humanoid.Health = 0 end)
The problem is that no matter how many different ways i try to do the second line it always says that Humanoid isn't a a child, can someone tell me how to find it or another way I could do this?
Thing is. You cant set a player health on a script you want to use a local script. If you still prefer a script then you wanna use :TakeDamage()
local db = false --using debounce cause takedamage can cause lag if used too much script.Parent.MouseClick:Connect(function(click) if db then return end db = true local char = click.Character char.Humanoid:TakeDamage(100) wait(5) --time until player spawns db = false end)
I'm not fully sure, but it may be that "click" is the Player in Game.Players, and not Game.Workspace, since Workspace is where Player's characters and humanoids are stored.
The reason your script isn't working is because you are getting the Player from game.Players, not the Character. It may seem a bit confusing, but when a person joins the game, Roblox splits your avatar into two things, a player(which is responsible for storing tools, GUIs, etc), and a character(which allows you to move around the world and do stuff).
When you clicked, what happens is that it returns the name of the player that clicked it, not the character.
In the script below, you get the character of the player, and set its health to 0.
script.Parent.MouseClick:Connect(function(click) local char = click.Character char.Humanoid.Health = 0 end)