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

Cloned item is a nil value?

Asked by 4 years ago

My code is like this:

script.Parent.Touched:Connect(function(V)
if V.Parent:FindFirstChildWhichIsA("Humanoid") and V.Parent:FindFirstChildWhichIsA("Humanoid").Name ~= "Zombie" then

local Cloned = V.Parent:Clone() -- I think it's the point.

end




end)

And the output said Cloned is a NIL VALUE What's going on!?

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

Assuming a player's character touched this, or some other object whose Archivable property is assigned to false, that is your issue.

By default, the character model is not Archivable. This property determines if an instance can be cloned.

Before cloning, simply assign Archivable to true;

local Players, Workspace = game:GetService("Players"), game:GetService("Workspace")

script.Parent.Touched:Connect(function(part)
    local client = Players:GetPlayerFromCharacter(part.Parent)

    if not client then
        return -- exit out the function since it wasn't a player who touched this part
    end
    client.Character.Archivable = true
    local clone = client.Character:Clone()
    clone.Parent = Workspace
end)

Notice I used better identifiers, and a more reliable way of verifying that a player touched it.

0
WOW DERP9487 41 — 4y
Ad

Answer this question