How to make a projectile go to a given Max Height

Hello, I am making a gun system and I have a specific location for the bullet to have a Max Height.
I am confused on how to get there with physics

I’ve tried various methods and prefer to manipulate the bullet part with “. Assembly” than using constraints since I haven’t found them useful due to their glitches.
I also tried using fast cast, but I rather have this for the individual bullets rather than a whole gun.

Thank you so much for your time !

What does a max height mean in this case? If it reaches that height it disappears? Or do you want to set the velocity so it physically cannot go higher than some height?

I want to set the velocity, so it physically reacher the max height and cannot go higher, thus falls down

If you shoot straight up the height will be based on this kinematic equation:
x = vt + 1/2 a t^2
where v is the initial upwards velocity and a is gravity’s acceleration (set in Workspace, will be negative). The max height will be x. You can rearrange this to find the max velocity you can allow for a given height.

I would do this in two different ways:

You could simply clamp the bullet position

local rs = game:GetService(“RunService”)

local Bullet = script.Parent
local MaxHeight = 1000

rs.RenderStepped:Connect(function()

      Bullet.Position = Vector3.new(Bullet.Position.X, math.clamp(Bullet.Position.Y, 0, MaxHeight), Bullet.Position.Z)

end)

or you could add a LinearForce to the bullet instance, increasing its vertical force as the bullet gets near the maximum height