How come this causes an error?

local newChar = game:GetService("Players").LocalPlayer.Character:Clone()

newChar.Parent = characterPreviewWindow
cam.Parent = workspace

Error: Players.matt1020304050.PlayerGui.InventoryGUI.InventoryScript:112: attempt to index nil with ‘Parent’

1 Like

The error is…
newChar is holding a nil value

Why it happens…
That depends, where is this script being used?
Are you using a local or server script?
Have you tried to use a task.wait() to make sure the character has loaded?

Character is loaded, and it’s a local script.

What do you get after this line, if you do
print("newChar = ",newChar)

1 Like

Set the Archivable property of the player’s character to true, clone it, then set it back to false (just a safety measure to avoid abuse by exploiters).

1 Like

Consider the use of game.Players.LocalPlayer.CharacterAdded:Wait() to make sure the Character is not nil.

This also could be because cam is nil - the error doesn’t specify which attempt to access the parent is nil. Make sure you are referring to workspace.CurrentCamera if you need to modify the player’s Camera.

Of course, this all belongs in a LocalScript.