Instance:Clone code sample attempts to index a nil value

The code samples documented on the Instance:Clone function page attempts to index a non-existent variable due to a slight oversight.


The issue lies on line 4.

local copy = model:Clone()

Error

image

should be

local copy = original:Clone()


Code sample w/ fix
-- Get a reference to an existing object
local original = workspace.Model
-- Create the model copy
local copy = original:Clone()
-- Parent the copy to the same parent as the original
copy.Parent = original.Parent
-- Move the copy so it's not overlapping the original
copy:SetPrimaryPartCFrame(CFrame.new(0, 50, 0))
2 Likes

There’s so many of these part of me wonders if they should unit test their examples, but that’s probably an over exaggeration to the problem :yum:

1 Like

Thank you for the report. This issue has now been resolved.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.