Pivoting issue when jumping

alr so I have this script for a 2d game and so when you turn u turn instantly right but the thing is when I jump and turn I get teleported to the ground

local Movement = game.ReplicatedStorage.RemoteEvents.Movement -- remote event, the remote evnt here is used to detect when the player is turning from the local side

local function Turn(player, Direction, CurrentDirection)
	player.Character:PivotTo(player.Character:GetPivot() * CFrame.Angles(0, math.rad(-180), 0)) -- this is the magic line where the player turns and here is where the solution and problem will be most likely


I don’t want the player teleporting to the floor please help