Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use Clone()? It literally does nothing for me but returns no errors either.

In my previous post, I was discussing how my remote for welding a weapon to my hand didn't work. But upon further inspection, Clone() literally didn't work at all.

When using Clone() inside the script, there literally wasn't any trace of a cloned model, not even a blank thing in explorer.

I tried to go into the game, and forcibly clone a part using the command console, nothing happened.

I put this inside one of my models

local parent = script.Parent
wait(10)
parent:Clone()

Nothing happened.

Literally nothing works, and it doesn't return errors in F9.
I've done stupid things in the past that I have fixed, but this has left me very stumped. If you know what's causing the error and could help, thanks.

1 comment

0

using Clone is like using Instance.new() you have to set a parent. Clone is just more useful for big things like tools.

2 answers

✓ Accepted answer

Your problem is that you're not setting a parent whenever you clone. Example:

local parent = script.Parent

local clone = parent:Clone()
clone.Parent = workspace

1 comment

0

Oh, thanks for the help. I guess this was just another stupid mistake.

When cloning Instances, you're always going to set a parent for the clone, I'm not sure why but that's just how it works

local objectClone = workspace.Object:Clone()
print(objectClone.Parent) --nil
objectClone.Parent = workspace
print(objectClone.Parent)--Workspace

And if you're going to clone an object without changing properties or anything inside of it, you can simply do:

workspace.Object:Clone().Parent = workspace

1 comment

0

"you’re always going to set a parent for the clone, I’m not sure why" It's really not all that complicated; just as an example, would you want to have the clone automatically be within the parent (lets say the Workspace), and have replication be altered after the fact. (Changing a part's colour for example.)

This discussion is preserved as it was. New answers, comments, and votes are closed.