Any ideas on how to make a gui that shows the surviving players?

Maybe I’m dumb or something, but I don’t even know where to start on this. This is my script so far

-- ss in sss
local PlayersLeft = game.ReplicatedStorage.Players -- intValue to show how many players left in numbers, I don't know how to display the name of the players
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local Humanoid = char.Humanoid
		Humanoid.Died:Connect(function()
			PlayersLeft.Value = PlayersLeft.Value -1
			print(PlayersLeft.Value)
		end)
	end)
end)

game.ReplicatedStorage.RoundOver.Event:Connect(function()
	local NumberOfText = PlayersLeft
	for _, player in pairs(game.Players:GetPlayers()) do
		player.PlayerGui.PlayersLeft.Enabled = true
		repeat Instance.new("TextLabel", player.PlayerGui.PlayersLeft.Frame) until
		#player.PlayerGui.PlayersLeft:GetChildren() == NumberOfText.Value
	end
end)

Basically, I’m trying to figure out how to get the surviving players name, that’s all.

1 Like

make a folder containing players and use this script:

local playerfolder = game.Workpsace.PlayersLeft

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		player.Character.Humanoid.Died:Connect(function()
			if playerfolder:FindFirstChild(player.Name) then
				playerfolder[player.Name]:Destroy()
			end
		end)
	end
end)

game.ReplicatedStorage.RoundStarted.OnServerEvent:Connect(function(player)
	for i,v in pairs(game.Players:GetChildren()) do
		local playervalue = Instance.new("StringValue")
		playervalue.Name = v.Name
	end
end)
2 Likes

How do you store all of the players in there? Like this?


game.Players.PlayerAdded:Connect(function(plr)
	local Name = plr.Name
	Name.Parent = workspace.PlayersLeft
end)

you need to make something to put the name of the player as. Like this:

local playervalue = Instance.new("StringValue")
1 Like

You could parent all characters in a folder and every time a child is removed detect if any children are left.