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

KillAllPlayers Script - Help?

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

  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.

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