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

Why is "local clone a nil value" in my script?

script.Parent.Touched:connect(function(charTouched)
	local character = charTouched.Parent --character
	local player = game.Players:GetPlayerFromCharacter(character) --player
	local clone = character:Clone()
	
	clone.Parent = game.Lighting
	character:Destroy()
	
	wait(2)
	
	clone.Parent = game.Workspace	
	character = clone
	
end)

I'm attempting to clone the player's character, store it in lighting, then destroy its current character. After 2 seconds, the clone goes into game.Workspace and then the character is set to clone. However, it states on line 6 that the variable for clone is a nil value. Why is this?

1 answer

✓ Accepted answer

Did you try to set the player's character to be archivable?

character.Archivable=true
local clone=character:Clone()

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