Script in part. Part is in workspace.
Part won’t clone??
while true do
task.wait(1)
script.Parent:Clone()
end
Script in part. Part is in workspace.
Part won’t clone??
while true do
task.wait(1)
script.Parent:Clone()
end
did anything print out in the output?
Is there anything in Workspace?
It does clone. If you want it to appear in the workspace, set the parent to workspace.
script.Parent:Clone().Parent = workspace
When you clone an Instance, the clone will automatically be parented to nil
. You’d have to set its Parent to the same as the original part’s Parent.
Also, I’d highly recommend using variables to make your code easier to read.
while true do
task.wait(1)
local clone = script.Parent:Clone()
clone.Parent = workspace -- OR clone.Parent = script.Parent.Parent
end
nil
is Lua’s nothing. It is a nonexistent datatype. If you’ve had experience in other languages, nil
is equivalent to null
. nil
is useful in many cases, such as cloning so that the part doesn’t appear in the workspace while you make changes to it. Here’s an example of nil
in action.
local items = {
Sticks = 3,
Rocks = 2
}
-- I want to destroy my sticks. Not even have 0. How?
items.Sticks = nil
-- All my sticks are gone. The table index isn't there anymore
print(items.Sticks) -- Prints nil, or nothing. No sticks. Not even 0.
Your part is being cloned, but not parented to workspace.
Roblox, by default, parents a cloned part to nil, therefore it is just being stored in memory, and not in the workspace.
To fix this, there is two ways.
1:
Store your clone in a variable and set the parent to workspace.
clonedPart = script.Parent:Clone()
clonedPart.Parent = game.Workspace
2:
Immediately set the parent to workspace.
script.Parent:Clone().Parent = game.Workspace
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.