Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way to lock Y position?

I want to make a hovering block. I want to lock the Y position, while able to move it (change the X and Z position.) Is there a way to fix this?

2 answers

If it's anchored, just script it carefully or constanttly reset its y pos to zero.

otherwise you can insert a bodyForce to counteract gravity.

part.BodyForce.force = Vector3.new(0, game.Workspace.Gravity, 0) * part:GetMass()

Additionally you can loop: wait until its position is not y, then continuously decrease its velocity until low, then briefly insert a bodyposition.

Have a "BodyVelocity" in the part and set the Y value in "Velocity" to whatever height you want.

1 comment

1

Body Velocities make the velocity of the part or model they are in equal to whatever the "Velocity" value is. If OP does what you said, the "hovering block" would actually move straight upwards at a speed equal to the Height he put in the Y value.

This discussion is preserved as it was. New answers, comments, and votes are closed.