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

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

Asked by 5 years ago

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.

0
using Clone is like using Instance.new() you have to set a parent. Clone is just more useful for big things like tools. namespace25 594 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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
0
Oh, thanks for the help. I guess this was just another stupid mistake. xForVowels 6 — 5y
Ad
Log in to vote
0
Answered by
blockmask 374 Moderation Voter
5 years ago

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
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.) TheeDeathCaster 2368 — 5y

Answer this question