Help with For Loop


local folders = workspace.Nations:GetChildren()
for _, folder in pairs(folders) do
	local team ="Team")
	team.Name = folder.Name
	team.Parent = game.Teams

Where the script is:
It does not make a team for every child in the Nations folder, I don’t understand what I’m doing wrong.

What does the output show? View > Output

Maybe the script doesn’t actually run? Try putting the script in ServerScriptStorage.


Thanks, put it in ServerScriptService and it printed the children and made the teams. I’m guessing that it doesn’t have access from Teams?

nothing, until I put it in ServerScriptService

Well, there are two types of scripts - Local scripts and Server scripts. Both of these types of scripts can run in only certain locations. For example, a server script can’t run in ReplicatedFirst because ReplicatedFirst holds local scripts. You can’t run a local script in ServerScriptService either, because ServerScriptService isn’t accessible by the client.

That’s great to hear :wink: Also consider marking my response as solved, thanks!

1 Like

thanks for the help dude, couldn’t have done it without ya :blush:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.