Alright, how would I move a part into a specific location? That’s all.
Example: I want Part A to move whatever direction Part B is, which is 10 studs away.
I tried to work with BodyVelocity, but I don’t know how(?) And I wouldn’t use tween because, I want it to be serversided, to avoid delays from client to server and vice versa, and also lag.
To save you time from thinking of a code, I’m trying to learn Lua, so please do not send scripts for me to copy and paste. I just want to know what should I do to achieve what the title of this thread is.
What do you mean to use their position attribute? I want Part A to move (not just teleport, but rather to move like, i want it to see moving) into Part B, thanks for helping!
responding to what @DiamondKingGuy63 said, the alternative is using RunService. You would need to define how long it takes to get there and your current time position. Increment the time position by the deltaTime provided by the function in RunService. Use CFrame:Lerp to move the part along according to the ratio of currentTime/totalTime. Finally disconnect the event when the object reached the goal.
I don’t use TweenService much but it definitely works and works smoothly.
Lerp is basically (exactly) what a tween is. Lerp gets a point some percentage between two points.
If you’re fine with using legacy body movers, you can use a BodyPosition and tween the position property. That will be smooth even if done from the server because it’s physics based so it’s interpolated (smoothed out on the client).
edit: typos
Instructions (server sided code):
Create a BodyPosition
Set MaxForce to Vector3.one * math.huge
Set Position to the part’s position
Add it to the part
Create a tween for the body position from the current part position to the goal
the reason why I want to to be serversided, because there would be more than one part that has to be moved, and each part would be treated differently. If it hit a player, it either kills them or damage them, thank you!