Why isn't this table cloning but it clones in a LocalScript?

Hello developers. I was scripting a for loop to clone an entire table. It worked, but then I moved it to a serverscript. When I moved it to the serverscript, it stopped working.

Here is the script:

local playerColorsFolder = Instance.new("Folder",player)
playerColorsFolder.Name = "PlayerColors"

for i,color in pairs(game:GetService("ReplicatedStorage"):GetChildren()) do
	if color.ClassName == "Color3Value" then
		print("yes") -- yes it prints yes the amount of times needed
		local playerColor = color:Clone()
		playerColor.Parent = playerColors
		playerColor.Name = color.Name
	end
end

Thanks for the help!

1 Like

try adding prints throughout the script so we can narrow in on the line of code that’s not working

local playerColorsFolder = Instance.new("Folder",player)
print("Test")
playerColorsFolder.Name = "PlayerColors"
print("Test1")
for i,color in pairs(game:GetService("ReplicatedStorage"):GetChildren()) do
	print("Test2")
if color.ClassName == "Color3Value" then
		print("yes") -- yes it prints yes the amount of times needed
		local playerColor = color:Clone()
print("Test4")
		playerColor.Parent = playerColors
print("Test5")
		playerColor.Name = color.Name
	end
end

Everything works, but for some reason, there is no clone.

is there a folder being created under player when testing?

I don’t know what you mean by that

Is there a folder being created when you play test your game? Check the explorer under Players

Can you confirm “player” isn’t nil?

1 Like

Yes a folder is created. Everything works besides the cloning.

I can confirm player is not nil

You put playerColor.Parent = playerColors instead of playerColor.Parent = playerColorsFolder.

2 Likes

Lol wow terrible mistake on my part

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