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

This script is not printing a table's values??

One part will print the other won't

local Payers = game:GetService("Players")

Ingame = {}
Outgame = {}

game.Players.PlayerAdded:connect(function(plr)
    local name = plr.Name
    repeat wait() until plr.Character
    local char = plr.Character
    
	table.insert(Outgame,plr.Name)
	print(unpack(Outgame)); -- It will print this 
end)

ValueToRemove = (unpack(Outgame));
for i = 1, #Outgame do -- Iterates through the table
    if Outgame[i] == ValueToRemove then -- If the value it's currently on is the same as the value you are attempting to remove then...
        table.remove(Outgame[i]) -- The value gets removed
wait(1)
		print(unpack(Outgame)); -- It will not print this
    end
end

1 answer

✓ Accepted answer

Your table only has one entry, therefore when you remove that single entry a call to unpack returns no values - And therefore nothing is printed.

In other news, just use table.remove(Outgame, 1) rather than your whole loop. It has the same effect. If this is not the effect you intended, then you need to have another look at your script and consider exactly why you're using unpack in the first place and therefore whether you understand what you're doing.

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