Mouse.Hit not working?

Hi, I’m trying to make my projectiles go exactly to the Mouse.Hit position, but for some reason Its Not going exactly to the mouse, why is this happening?

Any help is much appreciated! :+1: :grinning:

My current code for the mouse position:
Screenshot (94)

It goes to the mouse but is not accurate:
Screenshot (96)

How can I make it go exactly to the mouse?

1 Like

you forgot to show us everything else

1 Like

Maybe a bit more code would be handy to see? mouse should be referenced as Mouse.Hit I believe to get the Vector3 value of the LookVector

The direction of travel is mouse.Hit.p-object.Position

It works, but its not accurate, I’m not sure how showing rest of the script will help? this is basically the only thing that determines the mouse position, other then that, I just define the mouse.

There is nothing else in the script that determines the mouse position…

Can you explain more on that? I don’t understand what you mean?

So first of all, you’re aiming at the skybox so the cursor doesn’t really ‘hit’ anything and as such it will aim at a position an unspecified distance away. I’m not really sure what you’re doing since mouse doesn’t have a LookVector property anyways, but the direction from the object’s position to the mouse’s position (i.e. the direction it needs to fly) is mouse.Hit.p - object.Position.

Maybe try this? You could try setting the CFrame of the Projectile in relation to where the part first spawns and where the Mouse hits, then multiplying it by how fast you want it to go:

local Speed = 80
local Trajectory =, mouse).LookVector

BodyVelocity.Velocity = Trajectory * Speed

Idk this is what I remember from projectiles, and it seems to work for some reason

You are not wrong, but it is more efficient to do this. If you do it this way, it doesn’t waste resources coming up with a rotation matrix just so you can get a direction.

local Speed = 80
local Trajectory = (mouse-HumanoidRootPart.Position).Unit

BodyVelocity.Velocity = Trajectory * Speed
1 Like

I got this error when using your method:

Unit is not a valid member of CFrame

I got an error when trying that:


ServerScriptService.FireBall_Attack:53: invalid argument #2 to 'new' (Vector3 expected, got CFrame)

It’s because we don’t know what your variables are. But whether you are using my code or his it looks like you need to change mouse to mouse.p.

This is the rest of my code: (I don’t know how it can help you)

(My code was here, but I have the solution now)

There is more code after this, but that code is just damaging the humanoid the projectile hits.

I just showed you in an earlier post, it returns an error

It looks like you’re attempting to compare a CFrame value, when you should be getting the Mouse.Hit.Position instead in order to obtain a Vector3 value

Both of our codes should work fine, it’s just that you have to change what you’re passing from the client to the server (Or your Mouse.Hit, which is a CFrame)

1 Like

On my client script I’m doing Remote:FireServer(Mouse.Hit), should I change the client script or is the problem in the server script?

Just change it to


I believe mine & Jarod’s code were expecting the Mouse to be a Vector3 value when it was passed onto the server, but instead it ended up as a CFrame value which resulted in that error


Oh, ok, I understand now, thanks I’ll try it out. :grinning: :+1:

EDIT: Yeah it works now. Thanks for the help @JarodOfOrbiter and @Jackscarlett. I really appreciate it, I have had this problem now for a while, Thanks! :smiley: :+1: :sweat_smile: