Experiencing trouble moving players into a folder

I’m trying to place all players on the “Killers” team into a folder, and then remove them from that folder if they switch teams (I’ll be using this folder in further scripts to allow them to only affect members of the “Killers” team, so if you know an easier method to doing this then please let me know)

The problem is, in the line of code in which I change the character’s parent to the folder (line 7) there is an error I get which says “Attempt to index nil with parent”. Even though this line itself works just fine, the rest of the code is stopped from working because of the error (this stops the script from removing the players from the killers folder once they change teams).

I haven’t been able to find a solution yet, although I haven’t tried all of my options.

Here’s the code I’m currently working with:

local teamKiller = game:GetService("Teams")["Killer"]
local teamRunner = game:GetService("Teams")["Runner"]

	for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
		if (player.TeamColor == teamKiller.TeamColor) then
			player.Character.Parent = game.Workspace.KillersList
			if player.TeamColor ~= teamKiller.TeamColor then player.Character.Parent = game.Workspace

Do this

player.Character.Archivable = true

Doesn’t seem to be working, it says “Attempt to index nil with Archivable”. I guess it doesn’t know that I’m calling on a player which idk how to fix :confused:

Wait nvm I just reset and it switched me so I’d say for the purposes of my game that this is solved. Thank you!

1 Like