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

attempt to index local 'clone' (a nil value)?

Ok, so, I have this script:

game.Players.PlayerAdded:connect(function(player)
	
	repeat wait() until player.Character
	
	local random = math.random()
	
	local clone = player.Character:Clone()
	
	clone.Parent = game.ReplicatedStorage
	clone.Name = random.." player"
	
	player.Character:Destroy()
	
	repeat wait() until not player.PlayerGui.Intro.Develop
	
	local backClone = clone:Clone()
	backClone.Parent = game.Workspace
	backClone.Name = player
end)

And I have this error:

Workspace.Script:9: attempt to index local 'clone' (a nil value)

Ok, so, what's happening? It says I didn't define the 'clone' variable on line 9, but I did, on line 7!

1 comment

0

I am guessing, you can't clone, player's character, but it will not show errors if you do, and will show errors if you interact with it.

1 answer

✓ Accepted answer

I think you have to set the Player Model's "Archivable" property to true before you can clone it, as it might default to false.

1 comment

0

It worked!!! Thanks I_0KI ;)

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