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

How do I move an object to another object?

Asked by 6 years ago

I tried doing this but this didn't work

local placelocation = game.Workspace.Nets.Ballspawn.CFrame
      Part.CFrame = CFrame.new(placelocation)
0
are you trying to move a part or model? LoganboyInCO 150 — 6y

1 answer

Log in to vote
1
Answered by
xPolarium 1388 Moderation Voter
6 years ago
Edited 6 years ago

The constructor CFrame.new() needs a Vector3 position for it to create a new CFrame. Your error is placing a CFrame inside of it which isn't a Vector3.

You do have methods for setting position and rotations like this:

local location = workspace.Ballspawn.CFrame --This is the CFrame only

--We get the first 3 values (POS values) of the CFrame like this
Part.CFrame = CFrame.new(location.Position) --Vector3 inside of a .new()

--We can also just stick with the variable since it's a CFrame
Part.CFrame = location --Setting a CFrame to a CFrame

The difference to both examples is that the first wont keep the rotation of the location you're setting it to. That's because a CFrame is a matrix with the position and a rotation for an object.

You could just set the Part's position instead to do the same.

Note that the first 3 values to a CFrame are the (X, Y, Z) coordinates or the position of the CFrame

Ad

Answer this question