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

How to remove a string from GetChildren() ?

game:GetService('Teams'):GetChildren()

I want to remove a team from this table(I think this is a table) But I don't know how to do so.

Attempt 1 (Using table.remove())

Code :

local team = game:GetService("Teams"):GetChildren()
table.remove(team , "Lobby")

Output :

ServerScriptService.Script:2: bad argument #2 to 'remove' (number expected, got string)

Attempt 2 (Finding the position and then removing it with table.remove())

Code :

local team = game:GetService("Teams"):GetChildren()
print(team)

Output :

table: 0xe3a8b27dd6e99e38

Help is really appreciated!!!

1 comment

0

table.remove() take two argument. First one is the table, second one is the position of the key. But :GetChildren() is alway return a random order table, so it hard to know the position of "Lobby".

1 answer

✓ Accepted answer

Sadly, Roblox doens't supply a way to get the index of an item from an array. But you can use this workaround:

local teams = game:GetService("Teams"):GetChildren()
local team = teams.Lobby

for key,value in pairs (teams) do
	if team then
		table.remove(teams,team)
	end
end

Even then, why would you want to remove the team?

1 comment

0

you can do array[index] to get an item at a specific index

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