How do I offset a part from two walls?

I made the part dragging thing, and can offset it from one wall so that it doesn’t get halfway stuck
The new issue is, when I aim my mouse at one part, it can overlap with another part

I’m currently using raycasting and I find the distance to offset the part by with trig functions
Is there any way to fix this?

Out of curiosity, why not just set the part’s position to the ray’s hit position? See FindPartOnRay documentation WorldRoot | Documentation - Roblox Creator Hub

I think we’re going to need to see your code to help you much with this one.

EDIT: Actually the documentation on FindPartOnRay is basically useless. It returns a Hit Part and a Hit Position at the very least though.

that would happen, and this was the best I could do without overlaps

I assume you’re setting the part’s position to where the ray hit, can you create a BodyPosition object and put it inside of the part, then set the .Position property of the BodyPosition instead of the object itself, this will stop it from going through walls.

Also this might help you out, check it if you want

1 Like


It seems less smooth than adjusting the CFrame of the part, currently using 1250D and 17000P for both of them
Any suggestions on D and P values? Are either too high or too low?

1 Like

Check this place out, it got a very smooth system, it’s uncopylocked so you can examine it


I’ve checked it out last week, but it doesn’t have the effect I want
I’d actually like it to stick to walls, and that’s why I avoided using BodyMovers all along, though it seems I’ve made it work
What about models? How would I use BodyMovers to move them?

duh using welds and stuff how could i forget that
Anyway I marked your post as the solution, thanks!

1 Like