How to make player move towards mouse cursor

I’m working on a flying script but I have no idea how to make the player move horizontally toward the mouse cursor. It works diagonally but not horizontally.

Here’s a snippet of my script where I think the problem is occurring:

local glider = Instance.new("BodyVelocity", hrp)
	glider.Name = "Gliding"
	glider.MaxForce = Vector3.new(0,math.huge,0)

	local gyro = Instance.new("BodyGyro", hrp)
	gyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
	gyro.D = 100
	gyro.P = 10000

	while freefall do
		
		glider.Velocity = mouse.Hit.lookVector*50
		gyro.CFrame = mouse.Hit
		wait()
		end

I believe this post will cover what you need ;D
Edit: after reading this again I see that you want the player to move towards the mouse and the link I gave you was for using arrow keys. It may still help though

1 Like