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

Character's clone equal to nil?

Asked by 6 years ago
Edited 6 years ago

Im trying to write a script that duplicates your character then sets your character to the new one, but i keep getting this error ':5: attempt to index local 'cclo' (a nil value)' with this script:

local plr = game:service('Players').LocalPlayer
plr.CharacterAdded:connect(function()
local olc = plr.Character
local cclo = olc:Clone()
cclo.Parent = workspace
plr.Character = cclo
end)

btw its in a local script and it needs to be in a local script.

1 answer

Log in to vote
1
Answered by 6 years ago

It does not need to be in a local script. You’re also using lots of deprecated code. Let me help you.

It doesn’t clone because the Character’s Archivable property is set to false.

Set it to true, and it will work.

Put this code in a server script:

local PlayersService = game:GetService"Players" -- GetService not service

PlayersService.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character.Archivable = true -- set to true FIRST!!
        character:Clone().Parent = game.Workspace
    end)
end)
0
tysm i just said it needed to be in a local script because its in a script for script builder ThisIsAnAccount255 143 — 6y
Ad

Answer this question