So I’m getting and error with my script: Attempt to index nil with copy
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character
local copy = char:Copy()
copy.Name = ' '
copy.Parent = workspace
copy.HumanoidRootPart.Position = CFrame.new(workspace:WaitForChild('Game'):FindFirstChild('GreenScreen'):FindFirstChild('tp').CFrame)
for i,v in pairs(copy:GetChildren()) do
if v:IsA('Script') or v:IsA('LocalScript') then
v:Destroy()
end
end
end)
local char = plr.Character or plr.CharacterAdded:wait()
local copy = char:Clone()
copy.Name = ' '
copy.Parent = workspace
copy.HumanoidRootPart.Position = CFrame.new(workspace:WaitForChild('Game'):FindFirstChild('GreenScreen'):FindFirstChild('tp').CFrame)
for i,v in pairs(copy:GetChildren()) do
if v:IsA('Script') or v:IsA('LocalScript') then
v:Destroy()
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local copy = char:Clone()
copy.Archivable = true
copy.Name = ' '
copy.HumanoidRootPart.Position = CFrame.new(workspace:WaitForChild('Game'):FindFirstChild('GreenScreen'):FindFirstChild('tp').CFrame)
copy.Parent = workspace
for i, v in ipairs(copy:GetDescendants()) do
if v:IsA('Script') or v:IsA('LocalScript') then
v:Destroy()
end
end
end)
Like how @SOTR654 said, make the archivable property to true like so:
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local copy = char:Clone()
copy.Archivable = true
copy.Name = ' '
copy.Parent = workspace
copy.HumanoidRootPart.Position = CFrame.new(workspace:WaitForChild('Game'):FindFirstChild('GreenScreen'):FindFirstChild('tp').CFrame)
for i, v in ipairs(copy:GetDescendants()) do
if v:IsA('Script') or v:IsA('LocalScript') then
v:Destroy()
end
end
end)
But the script is cloning the character. If you clone something, you won’t be able to see it until it is parented to something. If there is no parent, then the code would be useless as the character clone would be stuck in memory.
I actually don’t know what the point of this code is, I’m just trying to solve the problem here which is that his code couldn’t access the character for whatever he needs it for.
Yeah ik, but he is cloning the character. That means that whatever change he made to the clone, he won’t do anything to actual character that the user would be currently playing in.
I don’t understand
since the script is dealing with the clone of a character and not the ACTUAL character itself. So you would need to parent the clone to something at least