Why is player not being cloned and C a nil Value?
Asked by
6 years ago Edited 6 years ago
While working on a script to clone the player's character I've come across the problem that its not cloning. What am I doing wrong here?
01 | script.Parent.Touched:Connect( function (part) |
02 | local Players = game:GetService( "Players" ) |
03 | local player = Players:GetPlayerFromCharacter(part.Parent) |
05 | part.Reflectance = 0.2 |
07 | part.Reflectance = 0.4 |
09 | part.Reflectance = 0.6 |
11 | part.Reflectance = 0.8 |
15 | local function crystalize() |
16 | if player.Character then |
17 | local c = player.Character:Clone() |
19 | c.Name = "SCP-409-1(" ..player.Name.. ")" |
21 | local d = c:GetChildren() |
23 | if d [ i ] .className = = "Accessory" then |
25 | d [ i ] .Handle.Transparency = 0 |
28 | if d [ i ] .className = = "Part" then |
29 | if d [ i ] .Name ~ = "HumanoidRootPart" then |
32 | if d [ i ] .Name = = "Head" then |
33 | if d [ i ] :FindFirstChild( "face" ) then |
41 | player.Torso:Destroy() |
EDIT: Put the full script opposed to the cut out.
Output:
Workspace.SCPs.SCP-409.Freeze:19: attempt to index local 'c' (a nil value)