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

How do I make a GUI that shows which players survived each round?

Hi, I am making a Survival Game where the players are in Jurassic World and they have to survive for all in all 9 minutes (there are three "rounds" but they don't do anything really do much besides change the words on the screen and keep track of time). I have two teams, Tourists (survivors) and Casualties (people who died). I want to make a Gui that shows up at the end of each 9-minute game and lists off the names of the players on the Tourists team just like every other survival game has. How would I do this? Thanks, Skyraider5

5 comments

0

Make an actual attempt and provide source code so we can help. Asking us "How would I do this?" questions with no source code doesn't help anybody.

0

Cmg, thank you for actually answering and trying to help instead of just giving some useless and unnecessary comment like some people I have seen tend to do. I will definitely try your script and don't worry about the GUIs those I can probably figure those out, thanks.

0

^^^

0

No problem, SkyRaider. If it doesn't work I'll be looking for comments on my question but if it does, please make sure to accept it and give both of us some reputation.

0

Just wanted to say, you said you created a GUI with the Tourist's name on it, but the names will change constantly, so you'll have to include that in your script.

1 answer

There are many ways you can do this, but the best way in lua is to create tables for casualties and tourists, and reset them at the end of every round. In order to do this, you would first need to connect the humanoid of every player to the died function, and add them to casualties, if they are found in tourists (you would also need to remove them from tourists) the script for connecting the humanoid is below:

-- This would be a `Server script` in `ServerScriptService`

local Tourists = {} -- Making the tourist table

if #Tourists == 0 then
	for i, v in pairs(game.Players:GetPlayers()) do --going through all the players
		table.insert(Tourists, v.Name) -- Inserting players name into Tourists
	end
elseif #Tourists > 0 then
	for i, v in pairs(Tourists) do
		table.remove(Tourists[i])
 --[[ Without the line above, on the second round their name would be 												
    	there twice, so we clear the table and then add all the players again.
	]]
	end
	for i, v in pairs(game.Players:GetPlayers()) do --going through all the players
		table.insert(Tourists, v.Name) -- Inserting players name into Tourists
	end
end

local Casualties = {} -- Creating Casualties table

game.Players.PlayerAdded:Connect(function(plr) -- When a player joins
	plr.CharacterAdded:Connect(function(char) -- When their character loads
		char.Humanoid.Died:Connect(function() -- When they die...
			for i, v in pairs(Tourists) do -- going through all the values in Tourists table
				if v == char.Name then -- Checking if their name is in there
					table.insert(Casualties, char.Name) -- if it is, add it to casualties
					table.remove(Tourists[i]) -- Removing their name from tourists
				end
			end	
		end)
	end)
end)

As for making the GUI's at the end of the round, you would have to figure that out yourself, as I can not see your whole game. I wish you luck and hope I helped so far.

-Cmgtotalyawesome

1 comment

0

Cmg, thank you for actually answering and trying to help instead of just giving some useless and unnecessary comment like some people I have seen tend to do. I will definitely try your script and don't worry about the GUIs those I can probably figure those out, thanks.

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