Hey! I will provide you with additional information aswell as the answer to your question.
So there are numerous ways to do this.
- Body Movers
These are the 3 basic ways to move a part.
CFraming is the most commonly used one, since it holds both Orientation and Position in an object. It’s made up of 4 Vectors:
- Position Vector
The ones with the directional faces (Look, Right, Up) make up the Orientation of the Part or object. The Position Vector makes up the position of where the Part or Object is located at.
So with CFrame, we can move a part by doing:
PartA.CFrame = PartB.CFrame * CFrame.new(3, 3, 3,) --XYZ This will Position a part 3 studs right, 3 studs up, and 3 studs foward.
Another use of CFrame is rotating objects, you can also combine the
CFrame.Angles() constructors by using a multiply symbol:
Part.CFrame = Part.CFrame * CFrame.new(4,4,4) * CFrame Angles(math.rad(45), 0, 0)
CFrame.Angles() is used to rotate an object, you can use math.rad() to provide a radian angle, like 45, 90, or 180.
So, at your level. A summary of CFrame is just basically Position & Orientation combined in an object that can be manipulated with the CFrame constructors to change Pos or Orientation.
PartA.CFrame = Part.CFrame * CFrame.new(0, 0, 10) This is an another example of a part being moved, make sure you define your part first.
Positioning isn’t the best way to move an object, since it doesn’t move the object based on it’s facing direction or relative to it’s orientation. I personally don’t use it and I would use CFrame over it.
Here’s a brief summary of Positioning though.
Every part or object will and most likely have a Position property. This describes the location of the object.
This property contains 3 axis values obviously, X, Y, and Z.
If you don’t know X describes left or right, Y describes up and down, Z describes foward and back.
If your part is rotated to the right 45 or 90 degress and you move your part right, it won’t move relative to where the part is facing based on that angle, that’s why CFrame is useful in this case.
To move a object with position, all you simply have to do is the following:
PartA.Position = PartA.Position + Vector3.new(3, 3, 3) This will move the object 3 studs right, 3 studs up, and 3 studs foward, not relative to where the part is facing though.
As you saw in the CFrame tutorial, we used the CFrame.new() and CFrame.Angles() constructor, for Position we use the Vector3 constructor. The Vector3 constructor essentially constructs a vector3 out of 3d space.
We can also use the Vector3 constructor for Orientation.
PartA.Orientation = PartA.Orientation + Vector3.new(45, 45, 45)
Body movers are a little bit different, the main Body movers you should use for positioning are:
These are the most basic 2 body movers that you can use to move an object. When using any type of body mover, the Object must be Anchored in order for it to apply to the part.
All you have to do to get a body mover working is insert it into a Part and play around with it, for this tutorial I will be using BodyPosition since it identifies as Position, and Body Velocity is just a infinite velocity with speed and direction applied to it.
BodyPosition consists of 3 properties you should worry about I will use BP to reference Body Position
BP.P and BP.Position are not the same thing, BP.P describes how long it should take for the Body Position to reach it’s goal, keep in mind, body movers are smooth movements based on their applied speed to the BP.P property.
I usually will set my P property to 50000, my MaxForce to
BP.MaxForce = Vector3.new(400000, 400000, 400000)
And for position, you can provide a position that you’d like to put in. For this tutorial, I’ll use 4,5,2
BP.Position = BP.Position + Vector3.new(4, 5, 2)
This will apply the Vector3 to the Position of the Body Position object.
I hope this helped!
I will now just kind of give you my thoughts on motivation and etc.
I have been scripting for 10 months now, I work on Anime games, particularly Dragon Ball. It is never easy to keep motivation, at all. For anyone, you will lose motivation some time sooner or later it just depends on your current state of reluctance to do something and your ideas you have.
When I first started scripting I was so bad, I watched a youtube tutorial on Custom Character, I read a comment that said “You have to unanchor the model, cmon guys.” I had no clue what he was talking about, see how bad I was? xD, I didn’t even know what Anchored meant. As I started progressing, I got better and better. I was in the same position as many other people are today where they are clueless, and trust me I’ve been there. a lot of times. You just gotta keep your head up and keep learning, if you got a question, just ask on the dev forum or look around on Google. Personally, what motivates me the most is getting better and learning. I’m currently getting better at advanced combat systems with different combos and it’s really fun because I’m learning a lot and making cool stuff. You do the same
If got something wrong or there is something inaccurate in my post, please reply to me and correct me, thank you.
Have a nice day and keep on scripting