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

How would one keep an object afloat at a certain Y position?

game:GetService("RunService").Stepped:Connect(function()
    script.Parent.BodyPosition.Position = Vector3.new(script.Parent.Position.X, 92.125, script.Parent.Position.Z)
    
end)

I feel like this isn't an optimal way of keeping something at a certain Y coordinate. I have no idea how to work the "Body" group of objects, can I get some help?

http://prntscr.com/kwtmc7

In the screenshot provided, the boat floats using the script shown above, I feel like there definitely is a better and more efficient way of doing it than this, since I feel like this will lag the server.

2 comments

0

as far as i know you can attempt to use body movers, but that uses render stepped, which i guess is the most efficient

0

idk, im noob at scripting

1 answer

✓ Accepted answer

You'd probably want to use a BodyPosition with a MaxForce of v3(0, amt, 0) with a high amount of dampening to make it more stable.

For example, if you wanted your part to hover at the coordinates v3(0, 10, 0), your settings on the BodyPosition could look something like this:

D = 1250, MaxForce = v3(0, 2000, 0), P = 10000, Position = v3(0, 10, 0),

which would result in something like this.

2 comments

0

Would that allow the part to move around by applying other BodyMovers like BodyThrust?

0

Yes, you could apply other forces as well.

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