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

Trying to Clone a model using CharacterAdded event is not working?

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
CharClone = char:Clone()
CharClone.Parent = workspace
CharClone.Position = Vector3.new(0,0,0)

end)
end)

I am trying to clone the model but it keeps saying workspace.Script.4: attempt to index global 'CharClone' (a nil value)

All im tryna do is just clone a single model but its not working is there any solution to this? and what is the reason this isnt working ?

1 answer

✓ Accepted answer

I am not very experienced with scripting but I have done something similar. If I am not wrong you are trying to clone from the Players instead of Workspace. So here is the fixed script.

game.Players.PlayerAdded:connect(function(plr)--This is the player from the player tab
local char = plr.Parent.Parent.workspace:WaitForChild(plr.Name) -- Finds the model of the player in the Workspace
char.Archivable = true
local clone = char:Clone()
clone.Parent = game.workspace
end)

My method of doing may be the most inefficient way in doing so but it gets the job done.

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