So I have a bit of code in my gun kit that allows you to dolphin dive and here is the code:
function Dive()
onGround = false
Prone()
spawn(function()
HRP.Velocity = HRP.CFrame.lookVector * 60 + V3(0, 40, 0)
wait(0.1)
HRP.Velocity = HRP.CFrame.lookVector * 70 + V3(0, 30, 0)
wait(0.4)
HRP.Velocity = HRP.CFrame.lookVector * 30 + V3(0, -10, 0)
end)
end
But for some reason the player only comes off the ground some of the time instead of every time the code is ran. I don't understand what is causing this and I would really appreciate it if I could be offered a solution to this problem. Thanks.
Here's a gyazo of what happens, if it helps.

4 comments
Try setting the velocity twice first time around. Sometimes the velocity of a part will (annoyingly) not change unless the command is executed twice in quick succession. However, it usually only happens to parts that are stationary, but it is worth a shot.
@BlackJPI, the velocity changes, but for some reason the player still doesn't go up sometimes
This is what I mean: https://gyazo.com/624410303ab58a176d1b75e9ba055bc8
@BlackJPI, I did that but that doesn't affect it. The velocity itself changes but the movement of the player doesn't reflect that