Character velocity RANDOMLY not changing

My code is supposed to launch the player in a given direction. It works 99% of the time. However, randomly upon a respawn it sometimes wont work.
I think it has something to do with the humanoid state type. if you look at my output windows it seems that the player’s state type is being overwritten very quickly for some reason. But I don’t know why. I think I can fix this by adding a breif loop that forces the humanoid state to change. I’m wondering if there’s a more elegant explanation or if this is just a ROBLOX bug.

Video of it breaking

Video of how its supposed to work

Here’s the code of how I’m changing the character’s velocity:

   		game:GetService("RunService").Heartbeat:Wait() --Velocity randomly doesn' change if I don't have this here
   		Character.Humanoid:ChangeState(Enum.HumanoidStateType.PlatformStanding)
   		Character.Humanoid.PlatformStand = true
   		body.AssemblyLinearVelocity = Direction*(Power*.8)+Vector3.new(0,Lift,0) ```