How to correctly using Mouse.Hit

Hello there,

So I have a plane and I’m using Mouse.Hit.p to determine how the plane should fly and rotation. However, when I aim it to the middle of my screen it jitters a lot and goes everywhere, has anybody had the same issue? Here is my code:

while true do
	if ThrottleIncrease then
		Throttle = math.clamp(Throttle + 1, 0, 100) -- The Throttle when increased is between 0 and 150. 150 is the max 0 is the lowest
	if ThrottleDecrease then
		Throttle = math.clamp(Throttle - 1, 0, 95) -- 100 should be fine.

	if BodyVelocity.Velocity.magnitude >= 50 then -- having the magnitude 50+ should be an accurate description if the plane is on ground or not
		InAir = true
		InAir = false

	if InAir then
		BodyGyro.MaxTorque =,math.huge,math.huge) 
		BodyVelocity.MaxForce =,math.huge,math.huge)

		BodyGyro.CFrame =,Mouse.Hit.p) * CFrame.Angles(0,-3.14/2+1.6,Seat.RotVelocity.Y/3) -- 3 and 3
		--BodyGyro.MaxTorque =,math.huge,0)
		BodyVelocity.MaxForce =,0,math.huge)

The relevant stuff is when I set the BodyGyro and BodyVelocity.

Any help is appreciated, thanks.

Mouse.TargetFilter = Plane --change plane to variable which is a reference to the plane model

This will blacklist (filter out) the plane model and its descendants from being targeted by the mouse (being set as the instance value assigned to the “Target” property of the mouse object).

1 Like

Wait, please could you quote when I used Mouse.Target or was that an example? also. If it was an example where should I implement it?

Yeah but, wouldn’t that just filter out 1 object? can’t I just use Plane like in the example you have provided?

TargetFilter filters/blacklists an instance and all of its descendants.

1 Like

Ohhh, thank you. However, could I just use a model such as Plane?

Yes, the plane model will be blacklisted/filtered and so will its descendants.

Hello! this significantly reduced the jittering and it rarely ever happens now but, when I make the mouse straight like not to either side of the plane the camera zooms in to my character then goes back out? I have seen this behaviour before but I am not sure what is causing it. Do you have any ideas?

I’ve not heard/encountered that issue before, I recommend starting a new thread and seeing if anyone else has encountered that same issue.

My only guess is that there’s a script setting the player’s min zoom/max zoom properties.