Body position moves part to wrong place

I’m trying to move a part with body position but the part is not in the same position when i click play.
image
The left part is where It should start but the right part is where it actually does start, and I made it move to the right and back to the left for the same distance each so the part never leaves that path. Before the body positions are created the part is where it should be but after they start moving it starts at the right part for some reason, goes to the right and back to the left. I want it to start from the left part go to the right then come back to the left.

Is it anchored? Probably is, but did you try using CFrames instead of Positions?

I need to use body position since I need the physics so the player can stay on top of the part, and no it isn’t anchored I don’t think body positions work if its anchored.

The sole reason it is moving on its own is due to it being unanchored. I’m assuming you’re looking for AlignPosition | Roblox Creator Documentation. This should be significantly better than BodyPosition.

How would I go about using align position, I need the part to move forward and backward the same distance, I thought align position would only allow it to move in one direction, unless I have to script the attachments changing although I’m not sure how it works. Also how would u keep the player on the part using align position?

Please don’t make multiple posts on the same topic.
<Does adding body positions to a part change the position of the part?

If you want a player to move with the platform just use a PrismaticConstraint. I made a sample for another Robloxian that you could use if you wanted.

Yes I know I made another post and I know its probably not the best thing to do but what should I do if my question isn’t answered, I assume after a few hours people can’t come across the post easily. Is there anywhere else I can ask? Also I’m somewhat new to the devforum and I wasn;t sure what to do.

You could bump your post by replying to it yourself, but just don’t bump it every hour.
give the PrismaticConstraint a try, I think it’ll solve your problem since Constraints use physics to move items similar to the BodyForces.

Alright thanks, I’ll try the prismatic constraint. Also how much time would u say would be acceptable for bumping the post?

I’d give it half a day or so, I know others and I will go back through a whole bunch of posts when we’re on the site to see what’s been marked as solved and try to help out with the ones that aren’t.

Also will using prismatic constraints not cause lag if they’re on the server, or should I make it locally? If it does have to be made locally, how do u set the attachments in a script?

I your first example does the moving Part actually need to be destroyed, or can’t it just stay on the server?

As for PrismaticConstraints they don’t lag the server unless you’ve got a ton of them, I’ve used them lots.

When Constraints first came out they used to be set up entirely with a script so all the instances had to be inserted that way, but they just made each instance available in studio so you can insert them there.

If you want to add an Attachment to a Part it’s just a matter of inserting the instance, but in your case you could already have the Attachment1 built within your cloned Part, have the PrismaticConstraint with the Attachment0 in it inside an Anchored Part () in the Workspace and use the script to set the Attachment1 to the new cloned Part’s Attachment1.

When u say does the moving part need to be destroyed I’m not sure what you’re talking about, the part that’s moving isn’t destroyed, its cloned from another part in a local script to make it local and it stays on the client till the player dies, then its destroyed and since the script runs again its cloned again. Also I’m not sure how to set the attachment through script, I tried setting the parent of the attachment0 to the cloned part(the part thats moving) then setting attachment1’s parent to another part assuming attachment0 moves towards attachment1 but the output says I’m attempting to index nil with Parent. This is my code I assume im not supposed to just set the parent of the attachment

local pc = Instance.new("PrismaticConstraint")
pc.Parent = part 
wait(10)
pc.Attachment0.Parent = part
pc.Attachment0.Position = part.Position
pc.Attachment1.Parent = game.Workspace.Attach

Don’t need to Parent it if it’s already in the Part.
Just do this:
Put the Attachment in an Anchored Part in the workspace.
In that Part insert an Attachment. You can change the name to whatever you want, but I’d just use Attachment 0.
Put a copy of your moving Part (make sure the original contains an Attachment named Attachment1) into the workspace temporarily where it needs to start out at with .
Go to the Constraints tool in the Model tab and choose the PrismaticConstraint and click the Attachment0 in your anchored Part, then click Attachment1 in your moving Part.
There will be some orange and yellow arrows in each Attachment when you select them. Make sure the arrows are pointed the same way in BOTH Attachments. If they aren’t aligned you’ll probably have red arcs showing which way they need to be rotated. I’m think it’s the yellow arrows that need to point in the direction of the travel of the Part. The green spheres of the Attachments should be in the same location in the workspace as well.
When it comes time to script it you can just do this:
Part(however you define the anchored one).PrismaticConstraint.Attachment1 = ClonedPart.Attachment1

Would it all be local if I did that? Also is there no other way to do this, it seems like it would be a tedious process when I start making 100s of these parts. If it is the only way then I am still willing to do it, but is there another option, maybe like fixing the body position issue, or will it always offset if I use body position?

you can change body position, rotation, and such even if the part is anchored.

Also, I don’t think this would work:


pc.Attachment0.Parent = part
pc.Attachment0.Position = part.Position
pc.Attachment1.Parent = game.Workspace.Attach


maybe remove the “Parent”:


pc.Attachment0 = part
pc.Attachment0.CFrame = part.CFrame — (I’m not too sure what you’re trying to achieve here but this looks wrong)
pc.Attachment1 = game.Workspace.Attach


Would like a longer version of the script if you still need help.

When I use body position on an anchored part the body position itself is moving however the part stays in the same position so its basically useless to keep it anchored. Also do u know why using body position to move a part would offset the part from its original position?

I’m not too sure but I do know that when using teleportation scripts, since I’ve tried to do some before, for example: If I use Body Position to move the humanoidrootpart to a teleport spot I want, it’ll only change the humanoidrootpart position to the spot i set it to, every other part of the player body will still be the same spot it was. CFrame doesn’t do that, CFrame teleports the humanoidrootpart and anything attached or rigged to it.

I can’t use CFrame since it doesn’t run physics on the part just changes its position and I need a player to be able to stay on the part if they walk on to it but for some reason using body position offsets the part by a little bit.

I mean your part isn’t anchored so when it clones it might move a little but other than that this other forum might help.