This script is supposed to print the names of current players in a game in TextLabels in a GUI in each player. However, the script is not doing anything, and output did not give me anything.

Can someone please help me?

Here's the script:

local playerCount = {}

game.Players.PlayerAdded:connect(function(player)
	local frameChildren = script.Parent.Frame:GetChildren()
	for i = 1, #frameChildren do
		frameChildren[i].Text = " "
	end
	wait()
	table.insert(playerCount, player.Name)
	wait()
	updateUI()
end)

game.Players.PlayerRemoving:connect(function(player)
    local frameChildren = script.Parent.Frame:GetChildren()
	for i = 1, #frameChildren do
		frameChildren[i].Text = " "
	end
	wait()
	table.remove(playerCount, player)
	wait()
	updateUI()
end)

function updateUI()
	for i = 1, #playerCount do
		script.Parent.Frame['Label'..i].Text = ""..playerCount[i]
	end
end

2 comments

0

can you test how far your script runs, this can be done by addeing prints ofter each line e.g. print('a'), print('b') ect

0

I did, and nothing printed.