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:

1local plr = game:service('Players').LocalPlayer
2plr.CharacterAdded:connect(function()
3local olc = plr.Character
4local cclo = olc:Clone()
5cclo.Parent = workspace
6plr.Character = cclo
7end)

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:

1local PlayersService = game:GetService"Players" -- GetService not service
2 
3PlayersService.PlayerAdded:Connect(function(player)
4    player.CharacterAdded:Connect(function(character)
5        character.Archivable = true -- set to true FIRST!!
6        character:Clone().Parent = game.Workspace
7    end)
8end)
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