How can i clone an object and move the clone 4 studs away?

Title says it all. ----------------------------------------------------------

2 Likes
local Object = object:Clone()

Object.CFrame = Object.CFrame * (0,0,4)

if you are confuse then Replace object with the part you want

3 Likes

Simply searching for this on Google would do the trick, but the basics are as follows:

  1. Define the object. For this example, local object = workspace.Part
  2. Set the PrimaryPart of the object. If you are simply doing this for a part, then this is not needed.
  3. Clone the object. local clonedObject = object:Clone()
  4. Change the position of the object. clonedObject:SetPrimaryPartCFrame(clonedObject.PrimaryPart.CFrame * CFrame.new(4,0,0))
  5. If you are simply using something such as a part, instead do this: clonedObject.CFrame = clonedObject.CFrame * (4,0,0)

I hope this helped you.

1 Like

I think it’s better practice to use

clonedObject.CFrame = clonedObject.CFrame + Vector3.new(0,0,4) --[[
           Change 0,0,4 the 4 to whichever direction you want it to move in
]]--

Why are you trying to make it complicated? And you forgot to parent the clone. A basic script’ll work.

local obj = obj:Clone()
obj.Position = Vector3.new(0, 0, 4)

obj.Parent = game.Workspace

They do the same thing.

1 Like

side note: for moving models, use the :MoveTo() method, as models dont have a .position or .cframe value (you can also use primarypart but i find this easier)

just an example didnt have intention to make full script on it

They gave the right answer in this case though and your answer is wrong. You aren’t moving the clone 4 studs away from the original object here, what you’re doing instead is setting the clone to the coordinates (0, 0, 4). If you want to move a clone away, then you need to do it relative to the original object’s position, not relative to the origin (0, 0, 0).

It’s the same thing and it works fine.

I didn’t say it doesn’t work, what I said is that your answer is wrong. More specifically the way you handle positioning is wrong because no it’s not the same thing, I’ve explained this in my post.

Your code doesn’t position an object four studs away from its original copy, it positions it 4 studs away from the world origin and that’s, if the title is interpreted as “clone 4 studs away from the original object”, not correct. Pushing the object 4 studs away would need to be handled relative to the original object, meaning taking its position and then offsetting it 4 studs away.

local clonedPart = part:Clone()
clonedPart.Position = part.Position * Vector3.new(0, 0, 4)
clonedPart.Parent = workspace

I already explained this stuff in my reply. It’s not about whether it errors or not, your answer is still not fully correct because you failed to account for a local offset and instead offset it from the origin.

1 Like

Models do have a :GetModelCFrame(), but it’s deprecated, since in some cases, it produces innacurate results.

1 Like