How would I make my wing script gain velocity while going down and lose velocity while going up?

Hi there, I need help with making my wing script gain velocity while going downwards and lose velocity while going upwards and if the velocity is too low then it cancels

This is my code I need help with

						if Flying and Float then

							local MousePos = Mouse.Hit.p
							local lookVector =,MousePos.Y,MousePos.Z)
							character.HumanoidRootPart.CFrame =,lookVector)
							FloatVelocity.Velocity = Mouse.Hit.lookVector*100
							GainedVelocity = FloatVelocity.Velocity.Y
							if GainedVelocity <= 15 then
								Flying = false
								Float = false
								local ActiveTracks = humanoid:GetPlayingAnimationTracks()
								for _,v in pairs(ActiveTracks) do



Can you not check whether or not the position of the wing on the Y axis has increased / decreased?

1 Like

How would I do that? I don’t know how to do it

1 Like

So I think based on your code you have the wing attached to the humanoidrootpart in some way?

If you grab the humanoidrootpart.Position it will return a Vector3, with any Vector3 you can reference a specific axis (x, y, z) like so.

HumanoidRootPart.Position.Y -- This is not a vector3 anymore, it's just a float / number

So if you have this defined outside of the scope of the runservice loop you can compare the last y position every step like so

local lastY = 0
local currentY = humanoidRootPart.Position.Y

if currentY > lastY then
-- they are higher than their last position
elseif currentY < lastY then
-- they are lower than their last position

lastY = currentY

This dosen’t seem like the thing I’m trying to do, I’m trying to make the player gain velocity while going downwards and lose velocity when going upwards with the wings, And also it’s a bodyvelocity

In that step though you can steadily increase or decrease the velocity based on the result of the if statement, no?

The problem is that I am not that good at scripting and don’t know how to do it

The Velocity property of the BodyVelocity is a Vector3 I’m pretty sure, so you can directly update the value of it like you would set the position of a part.

Hmm, I’ll try it right now and I’ll tell you if I succeed

You could do:

BodyVelocity.Velocity +=, (HumanoidRootPart.Y - LastYPosition) * delta, 0)

BodyVelocity = Your BodyVelocity instance
HumanoidRootPart = the primary part of the character model
LastYPosition = The Y position of the HumanoidRootPart in the previous frame.
delta = the only parameter of RunService.RenderStepped(Float: delta)

Hope this works.

This dosen’t change anything when I use it with my script

It didn’t work with my code hmmm