Making a sharp turn glitches the horse model

Making a horse system right now, the riding works great. but, when it comes to leading the horse, i made it detect whenever the humanoid move direction off the player changes, and made the horse replicate that. But as you can see in the video below, turns will make the horse glitch. How can i fix this?

**function HorseLeading(Character: Model)
	IsLeading = true
	Character:WaitForChild("Humanoid").WalkSpeed = 4
	Seat.TurnSpeed = 5
	Model.PrimaryPart:SetNetworkOwner(game.Players:GetPlayerFromCharacter(Character))
	local currentstate 
	Humanoid.WalkSpeed = 4
	
	coroutine.wrap(function()
		local plrHumanoid = Character:WaitForChild("Humanoid")
		plrHumanoid.WalkSpeed = 6
		plrHumanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
			
			if (Model.PrimaryPart.Position - Character.PrimaryPart.Position).Magnitude >= 25 then
				Model:PivotTo(CFrame.new(Character.PrimaryPart.Position + Vector3.new(0,0, -2)))
			end
			local movedirection = game.ReplicatedStorage.GetPlayerCFrame:InvokeClient(game.Players:GetPlayerFromCharacter(Character), plrHumanoid.MoveDirection)
			--local movedirection = Character.PrimaryPart.CFrame:VectorToObjectSpace(plrHumanoid.MoveDirection)
			if math.round(movedirection.X) == -1 then
				print("Walking left!")
				Humanoid.WalkSpeed = 7
				Seat.Steer = -1
			
				RightTrack:Stop()
				if not LeftTrack.IsPlaying then
					LeftTrack:Play()
				end
				
			elseif math.round(movedirection.X) == 1 then
				print("Walking right!")
				Humanoid.WalkSpeed = 7
				if not RightTrack.IsPlaying then
					RightTrack:Play()
				end
			
				LeftTrack:Stop()
				Seat.Steer = 1
			elseif math.round(movedirection.Z) == -1 and currentstate ~= "Walk" then
				print("Walking forward!")
				currentstate = "Walk"
				Humanoid.WalkSpeed = 4
				
				Seat.Throttle = 1
				Seat.Steer = 0
				walk()
			elseif math.round(movedirection.Z) == 1 and currentstate ~= "Backwards" then
				print("Walking backward!")
				Humanoid.WalkSpeed = 4
				Seat.Steer = 0
				currentstate = "Backwards"
				backwards()
			elseif math.round(movedirection.Magnitude) == 0 and currentstate ~= "Idle" then
				currentstate = "Idle"
				Humanoid.WalkSpeed = 0
				Seat.Throttle = 0
				Seat.Steer = 0
				idle()
			end
		end)
	end)()

end

Client:

game.ReplicatedStorage.GetPlayerCFrame.OnClientInvoke = function(movdir)
	return workspace.CurrentCamera.CFrame:VectorToObjectSpace(movdir)
end
	
1 Like