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

Why is "local clone a nil value" in my script?

Asked by 8 years ago
script.Parent.Touched:connect(function(charTouched)
    local character = charTouched.Parent --character
    local player = game.Players:GetPlayerFromCharacter(character) --player
    local clone = character:Clone()

    clone.Parent = game.Lighting
    character:Destroy()

    wait(2)

    clone.Parent = game.Workspace   
    character = clone

end)

I'm attempting to clone the player's character, store it in lighting, then destroy its current character. After 2 seconds, the clone goes into game.Workspace and then the character is set to clone. However, it states on line 6 that the variable for clone is a nil value. Why is this?

1 answer

Log in to vote
1
Answered by 8 years ago

Did you try to set the player's character to be archivable?

character.Archivable=true
local clone=character:Clone()
Ad

Answer this question