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

attempt to index local 'clone' (a nil value)?

Asked by
OfcPedroo 396 Moderation Voter
7 years ago

Ok, so, I have this script:

game.Players.PlayerAdded:connect(function(player)

    repeat wait() until player.Character

    local random = math.random()

    local clone = player.Character:Clone()

    clone.Parent = game.ReplicatedStorage
    clone.Name = random.." player"

    player.Character:Destroy()

    repeat wait() until not player.PlayerGui.Intro.Develop

    local backClone = clone:Clone()
    backClone.Parent = game.Workspace
    backClone.Name = player
end)

And I have this error:

Workspace.Script:9: attempt to index local 'clone' (a nil value)

Ok, so, what's happening? It says I didn't define the 'clone' variable on line 9, but I did, on line 7!

0
I am guessing, you can't clone, player's character, but it will not show errors if you do, and will show errors if you interact with it. thesit123 509 — 7y

1 answer

Log in to vote
0
Answered by
I_0KI 40
7 years ago

I think you have to set the Player Model's "Archivable" property to true before you can clone it, as it might default to false.

0
It worked!!! Thanks I_0KI ;) OfcPedroo 396 — 7y
Ad

Answer this question