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

"Attempt to index local 'clone' (a nil value)?"

Asked by
JJ_B 250 Moderation Voter
8 years ago

I made a tool that copies your character when you activate it, however I keep getting the error: Players.Player1.Backpack.Mirage/Remnant.LocalScript:9: attempt to index local 'clone' (a nil value) I have no idea what this means nor how it can be rectified. The script is here:

local name = game.Players.LocalPlayer.Name .. "RNT"

script.Parent.Activated:connect(function()
    if not game.Workspace:FindFirstChild(name) then
        local m = Instance.new("Model")
        m.Name = name
        m.Parent = game.Workspace
        local clone = game.Players.LocalPlayer.Character:clone()
        clone.Parent = m
        clone.Torso.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector*2
        clone.Name = ""
        clone.Humanoid.MaxHealth = 0
    else
        game.Workspace[name]:destroy()
    end
end)

Can anyone help?

1
I am pretty sure you can't clone the player, I tried it before thehybrid576 294 — 8y
0
you're right, i just tested it Perci1 4988 — 8y
0
Well that sucks JJ_B 250 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

You can clone the player, but only when the model's Archivable value is set to true. It basically means it gets remembered by the game. Never set something's Archivable value to false, it'll delete itself the next time you run/load your game.

So, try and set it to true. Also, call Clone() with capitals, the lowercase version is deprecated:

part:Clone()

Hope I helped!

~TDP

Ad

Answer this question