Hi there, I am trying to make a part placement system and I am currently having trouble with making the part go on top of others, It just keeps flying up, if anyone can help I would appreciate it a lot, here is the code
repeat
task.wait()
Place.Position = Vector3.new(mouse.Hit.Position.X, Place.Position.Y + mouse.Target.Position.Y + mouse.Target.Position.Y/2, mouse.Hit.Position.Z)
Place.Orientation = Vector3.new(0, 0, 0)
print(Place.Position.Y, mouse.Target)
until Clicked == true
In your loop you are continually adding to the parts y postiion with this:
Place.Position.Y + mouse.Target.Position.Y + mouse.Target.Position.Y/2
Without the resto of your code, it’s hard to give an idea of how to solve your problem (mouse is only 2D not 3D), but to solve the issue of your Place object going up, you should take the position of where it is first outside the loop, then use that as the reference and add your mouse y on:
local startY = Place.Position.Y
repeat
task.wait()
Place.Position = Vector3.new(mouse.Hit.Position.X, startY + mouse.Target.Position.Y + mouse.Target.Position.Y/2, mouse.Hit.Position.Z)
Place.Orientation = Vector3.new(0, 0, 0)
print(Place.Position.Y, mouse.Target)
until Clicked == true