Cloning the Player Character is invalid

Hello!

In my server script I have cloned the character however the clone is nil. While the character is valid.

Script:

for i = 1, math.min(3, #ranked) do
				local rank = i == 1 and "🏆 First" or i == 2 and "🥈 Second" or "🥉 Third"
				print(rank .. ": " .. ranked[i].player.Name .. " (" .. ranked[i].height .. " blocks)")
				
				local character = ranked[i].player.Character
				
				print("Character type:", typeof(character), character.ClassName)

				if character then
					print("Character found") -- It found the character
				else
					print("Could not find character")
				end
				
				local clone = character:Clone()
				if clone then
					print("Clone valid")
				else
					print("Clone invalid") -- The clone was invalid/nil
				end
				
				if i == 1 then
					clone.Parent =  workspace -- Error:   19:50:24.463  ServerScriptService.ServerScripts.Rounds.RoundScript:177: attempt to index nil with 'Parent'  -  Server - RoundScript:177
				elseif i == 2 then
					clone.Parent = workspace.Map.Podium.Second
				elseif i == 3 then
					clone.Parent = workspace.Map.Podium.Third
				end

The main reason of this error is that the clone is nil and I am sure I wrote it correctly. I have no idea why the cloning is nil.

Before you clone the character, you have to set its Archivable property to true

3 Likes

Thank you!

I added that and know the cloning works!

1 Like

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