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

Why is player not being cloned and C a nil Value?

Asked by 5 years ago
Edited 5 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?

script.Parent.Touched:Connect(function(part)
    local Players = game:GetService("Players")
    local player = Players:GetPlayerFromCharacter(part.Parent)
    wait(1)
    part.Reflectance = 0.2 
    wait(3)
    part.Reflectance = 0.4
    wait(3)
    part.Reflectance = 0.6
    wait(3)
    part.Reflectance = 0.8
    wait(5)
    part.Reflectance = 1

    local function crystalize()
        if player.Character then
            local c = player.Character:Clone()
            c.Parent = workspace
            c.Name = "SCP-409-1("..player.Name..")"

            local d = c:GetChildren()
            for i = 1, #d do 
                if d[i].className == "Accessory" then 
                    d[i].Mesh.TextureId = "http://www.roblox.com/asset/?id=686337933"
                    d[i].Handle.Transparency = 0
                    d[i].Anchored = true
                end
                if d[i].className == "Part" then 
                    if d[i].Name ~= "HumanoidRootPart" then
                        d[i].Anchored = true
                        d[i].Transparency = 0
                        if d[i].Name == "Head" then
                            if d[i]:FindFirstChild("face") then
                                d[i].face:Destroy()
                            end
                        end
                    end
                end
            end
        end
        player.Torso:Destroy()
    end
    crystalize(part)
end)

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)

1
With the players model you need to set Archivable to true before cloning the player. User#5423 17 — 5y
0
It is set true but still nothing. If I need to post the whole script I can. BlauKitten 88 — 5y
0
You probably also need to set the position of the model or it may just be falling off the map User#5423 17 — 5y
0
All the original parts from the player are anchored before the clone is made. BlauKitten 88 — 5y
View all comments (8 more)
0
What is "part"? Is this is a global? If it's from a touched event, it isn't being passed to your function "crystalize()". Include it by doing "crystalize(part)". Cousin_Potato 129 — 5y
0
crystalize is in the function where local part is defined. Also tried crystal(part) and still getting the same thing. BlauKitten 88 — 5y
0
Because, you really never got the character... greatneil80 2647 — 5y
0
Can you that code as well? (The part where part is defined and function is called.) Cousin_Potato 129 — 5y
0
If I need to I can post the full code if it makes things any easier. BlauKitten 88 — 5y
0
Yes please Cousin_Potato 129 — 5y
0
I edited the question desc and put the full script there. BlauKitten 88 — 5y
0
Try making sure that it's a humanoid touching the part? B_rnz 171 — 5y

1 answer

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

Try enabling "Archivable " right before you clone it.

(Line 17-ish):


local character = player.Character character.Archivable = true local c = character:Clone() character.Archivable = false
1
That seemed to do the trick. Thank you! BlauKitten 88 — 5y
Ad

Answer this question