Attempt to index Nil (Clone) with Workspace

Hio,

I’m attempting to create a cutscene in my game in which the local player can see their character model. I have cloned the character via a local script, but I cannot get past the error: “attempt to index nil with parent”. The script follows a remote event, by which a server script fires an event to the local script in question.

Below is the script under scrutiny:

local Start = game.Workspace.AgentCutscene["AgentCutscene - NPCStart"]
local Destination = game.Workspace.AgentCutscene["AgentCutscene - NPCDestination"]

game.ReplicatedStorage.AgentCutscene.onClientEvent:Connect(function()
	print("event received")
	local Dummy = game.Players.LocalPlayer.Character:Clone()
	Dummy.Parent = workspace
	Dummy.Position = Start
end)

Any advice?



Roblox doesn’t want you to clone player instances for a good reason (?)

1 Like

Yep, that’s definitely some good insight there.

Is there a way to clone all of the model’s children in the process as well? A character’s position as an object cannot be determined, so I must take its HumanoidRootPart, which doesn’t exist in the cloned model.

game.ReplicatedStorage.AgentCutscene.onClientEvent:Connect(function()
	print("event received")
	local Dummy = game.Players.LocalPlayer.Character
	Dummy.Archivable = true
	local ClonedDummy = Dummy:Clone()
	Dummy.Archivable = false
	
	ClonedDummy.Parent = workspace
	ClonedDummy.HumanoidRootPart.Position = Start
end)

1 Like

May I ask what are you aiming for by cloning player models? As I said, Roblox discourages it probably for a good reason

If you still really need to, you might need to end up writing your own custom cloning function that manually scans over properties and transfer them over into a new instance

Also, consider reading this:

2 Likes

This is to do with a cutscene in which the player’s avatar is seen in my game. Since this is a multiplayer experience, a single object must be the framework upon which the client’s character can be seen. Essentially, each client in the server will see their own character on the screen.

Refer to the thread I shared above.

If you really need to, you can set the model’s primary part to the torso or wherever you want to pivot the model from, and then change the position of that part.