Player Animation.

I’m making some custom movements, and I’m setting an animation. When the player is on the ground and jumps the animation isn’t set, they still look like they’re running. But when I jump a second time in the air, the animation is set correctly.

[lua]hook.Add(“Move”, “BallonMove”, function(ply, movement)

if ply:KeyPressed(IN_JUMP) then
	
	if ply:KeyDown(IN_FORWARD) then
		
		movement:SetVelocity(Vector(0, 0, UpPower) + ply:GetAimVector()*DirPower)
		
	elseif ply:KeyDown(IN_BACK) then
		
		movement:SetVelocity(Vector())
		
	elseif ply:KeyDown(IN_MOVERIGHT) then
		
		movement:SetVelocity(ply:GetVelocity() + ply:GetRight()*DirPower*2)
		
	elseif ply:KeyDown(IN_MOVELEFT) then
		
		movement:SetVelocity(ply:GetVelocity() + ply:GetRight()*DirPower*-2)
		
	elseif ply:IsOnGround() then
		
		movement:SetVelocity(Vector(0, 0, UpPower) + ply:GetForward()*DirPower)
		
	else
		
		movement:SetVelocity(Vector(0, 0, UpPower) + ply:GetAimVector()*DirPower)
		
	end
	
	ply:ResetSequence(ply:SelectWeightedSequence(ACT_HL2MP_JUMP_SLAM))
	
	return true
	
end

end)[/lua]

I believe it has something to do with Entity:SetGroundEntity