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

How can I get all players that aren't in a group and display them on a TextLabel?

My issue: I can't seem to get this script to actually apply the unpacked table to the TextLabel at the end of the script. There are no warnings or errors in the output.

What it's supposed to do: This script is supposed to get all of the people who aren't in the group and display them on the InfoScreen

What I've tried:

  • I've put various prints throughout the script (beginning, allplayers before changes, allplayers after changes, and the end) and they all printed successfully
  • I have put an if statement in the end to check if the table was nil before actually applying it to the TextLabel
local Players = game:GetService("Players")

local text = script.Parent:WaitForChild("People").Text


Players.PlayerAdded:Connect(function(player)
    
    local allplayers = game.Players:GetChildren()
    print(unpack(allplayers))

    for i=1,#allplayers do
        if allplayers[i]:IsInGroup(1) then
            table.remove(allplayers,i)
        end
    end
    
    
    text = unpack(allplayers)

    
end)

1 answer

unpack converts a table into a tuple. You would have to perform a loop and concatenate all the player's names together like so:

function PlayerTableToString(t)
	local string = ""
	for i,v in pairs(t)do
		string = string .. v.Name .. " " -- add the player's name to the string and leave a space for the next player's name. You might want to customize that to be an end line or something but that's up to you.
	end
	return string
end

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