adminGame = game.StarterGui.AdminGUI.AdminGame game.StarterGui.MouseButton1Click:connect(function(kill) if adminGame.MouseButton1Click == true then local game.Players.Humanoid.Health = 0 else adminGame.MouseButton1Click = false end end)
It's not working. What it does is when I press the TextButton (AdminGame), all the players die in game. I seem to got the pressing button part right, but no player dies. Help?
MouseButton1Click fires whenever a player clicks a specific GuiObject. You would want to connect it to the actual button instead of the service game.StarterGui
.
You are trying to get to Humanoid
as if it were a direct descendant of Player
, which it is not.
Perhaps explain what AdminGame
is and how it is related to the clicking event.
You would have to loop through every player in the Players
service in order to have them all killed.
The following assumes that GuiObject
is the button you want to click...
GuiObject.MouseButton1Click:connect(function() for i, player in ipairs(game.Players:GetPlayers()) do local character = player.Character character:BreakJoints() end end
The BreakJoints
method used on line 4 would break all joints (Welds, JointInstances) located inside the model character
, therefore killing the player.