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

how to make a Amount of players alive gui?

I am looking on how to make a players alive gui, so in my game i want a image of the player, and a x across the player if the player has died, how would i do that?

2 comments

0

This is not a request site, Attempt to make a script and then when you are unable to do something you then request help.

0

make a bool, set it to true, later when they die, set it to false.................... and then make the text say one less..

1 answer

I won't give you an exact guide on how to do everything you asked for since this is scriptinghelpers and not scripting*-do-everything-for-me-so-I-don't-have-to*, but I'll give you a general hint.

Alright, so we want a script that checks if any player has died. What is the first thing we need for that? Correct, a list of all players. We could just use game.Players:GetPlayers() for this, but that'll only look for current players and not keep update automatically whenever a player joins or leaves. So what we need to do here is using events that'll call each time a player either joins or leaves. We can do that the following way:

game.Players.PlayerEntered:connect(function(player) -- A player has entered
	player.Character:WaitForChild("Humanoid") -- Wait until the humanoid has loaded
	player.Character.Humanoid.Died:connect(function() -- The character has died
		print(player.Name.." has died!") -- Show that the player has died. In your case we'll do something a bit more complex.
	end)
end)

Okay, so now we have a way of finding out if a player character dies. But we want all players to be able to see that, right? So what do we do to make every player able to see it? We run this script on the server side and use a RemoteEvent to show every player that someone has died. We'll do it the following way:

-- Put this into the Script on the server side (Workspace)

game.Players.PlayerEntered:connect(function(player) -- A player has entered
	player.Character:WaitForChild("Humanoid") -- Wait until the humanoid has loaded
	player.Character.Humanoid.Died:connect(function() -- The character has died
		script.Parent.YourEventName:FireAllClients(player.userId) -- Change "YourEventName" to the name of your event. We use the userId because that's a reliable, unique identifier.
	end)
end)
-- Put this into a LocalScript on the client side (PlayerScripts)
game.Workspace.YourEventName.OnClientEvent:connect(function(plrid)
	Died(plrid) -- You could make this a function that crosses dead players out.
end)

I hope that quick tutorial helped you. If you have any further questions, feel free to ask in the comments below.

2 comments

0

large.......

0

scripting-do-everything-for-me-so-I-don't-have-to LOL

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