Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

KillAllPlayers Script - Help?

Asked by 9 years ago
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?

1 answer

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago
  1. 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.

  2. You are trying to get to Humanoid as if it were a direct descendant of Player, which it is not.

  3. Perhaps explain what AdminGame is and how it is related to the clicking event.

  4. 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.

Ad

Answer this question