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

How would I clone a character on spawn?

Asked by 5 years ago

I have a clone character on spawn script but it gives me a "attempt to index local 'd' (a nil value)" error. How would I fix this? Here is my server script:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        wait(5)
        local d = char:Clone()
        d.Parent = game.Workspace

    end)
end)
0
you would have to set char.Archivable to true first GoldAngelInDisguise 297 — 5y
0
Thank you CaptainD_veloper 290 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Try this!

game.Players.PlayerAdded:Connect(function(plr) --player added
    plr.CharacterAdded:Connect(function(char)  --character added

        wait(5)
        char.Archivable = true  --it will return nil if the cloned object is not archivable
        local clone = char:Clone() 
        clone.Parent = game.Workspace --Put it in workspace

    end)
end)

I hope this worked!

0
Doesn't solve the problem. User#24403 69 — 5y
0
Doesn't???? WideSteal321 773 — 5y
0
Try yourself. WideSteal321 773 — 5y
0
Thanks for accepting! WideSteal321 773 — 5y
0
you need to explain the script. and after clone disable archivable yHasteeD 1819 — 5y
Ad
Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

Problem

You forgot to set archivable of player to true You need to set true "Archivable" in player model for fix it. If archivable is false, you can't clone. if archivable is true, you can clone. Remember: All characters spawn with archivable false.

What archivable makes?

Determines if an Instance can be cloned using Instance:Clone or saved to file

Correction

For your code you need to set archivable of player to true, after clone set to false.

Example:

local obj = workspace.Model
Obj.Archivable = true
local clone = Obj:Clone()
clone.Parent = workspace
Obj.Archivable = false

Fixed script:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        wait(5)
        char.Archivable = true
        local d = char:Clone()
        d.Parent = game.Workspace
        char.Archivable = false
    end)
end)

Hope it helped :)

Wiki pages: Archivable


If works, not forgot to accept a answer or put [SOLVED] in title.

0
do not, not just not WideSteal321 773 — 5y

Answer this question