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

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

Asked by 5 years ago
Edited 5 years ago
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

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question