Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to index nil with 'Parent' when cloning the players character?

Asked by 2 years ago
Edited 2 years ago

Hi so i'm trying to clone the character and then when i set the parent of the character it just pastes out a error I'm also trying to make a local because i want to make a menu with the player

Here's the script:

local character = game.Players.LocalPlayer.Character:Clone()
character.Parent = workspace

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

This is due to the Archivable property. If this property is set to false, this will prevent objects from being cloned.

Using the Clone() method on an object that is not archivable will return nil, hence the error you're receiving.

As the Character's Archivable property is automatically set to false, you'll need to set it to true before using the Clone() method.

local character = game.Players.LocalPlayer.Character
character.Archivable = true

local characterClone = character:Clone()
characterClone.Parent = workspace
Ad

Answer this question