Mouse.hit not changig part orientation

So I’m trying to make a projectile that goes wherever the user’s mouse is aiming, and to do so I need the projectile’s orientation to be aiming correctly, but whenever I run my script this isn’t the case.
The script and lines:

Whenever I use it the projectiles don’t aim, so how would I fix this?

Try mousehit.Position + mousehit.LookVector instead of mousehit.LookVector only

I tried this and it did’t work, but i added * Vector3.new at the end of your suggestion and it changed it a bit

It still doesnt work though Im actually confused rn

I noticed that you’re setting the projectiles’ CFrame right before you’re setting the orientation

If you want the projectiles to start at the fx positions then all you need to do to both position and rotate them is:

proj1.CFrame = CFrame.lookAt(fx1.CFrame.Position, mousehit.Position)

Okay so I implemented your script, I whats happening rn

script:

proj1.Parent = workspace
proj2.Parent = workspace
proj1.CFrame = CFrame.lookAt(fx1.CFrame.Position, mousehit.Position)
proj2.CFrame = CFrame.lookAt(fx2.CFrame.Position, mousehit.Position)
proj1.Orientation = mousehit.Position + mousehit.LookVector
proj2.Orientation = mousehit.Position + mousehit.LookVector

robloxapp-20231221-1405332.wmv (2.7 MB)

There’s no need to also set the orientation if you’re using CFrame.lookAt, it will cause problems if you still do so you can remove these lines:

proj1.Orientation = mousehit.Position + mousehit.LookVector
proj2.Orientation = mousehit.Position + mousehit.LookVector

Deleted it and it’s still not working, but it seems like wherever I aim the projectile is aiming a certain amount of degrees away from where I aim

I think the bodyvelocity is moving the projectiles off the target so try changing:
slide1.Velocity = mousehit.LookVector (do so for slide2 as well)
to:
slide1.Velocity = proj1.LookVector

For some reason it says LookVector is not a property of the projectiles

1 Like

Yea that was a mistake I made, sorry

I meant to write proj1.CFrame.LookVector

Oh ok
Anyways I put that in and now it works better, I just have to figure out how to turn it because whenever I aim at something its doing this

1 Like

The easiest way to solve this is by using an AlignOrientation using TwoAttachment mode

You’ll need to create one for each projectile and an attachment on each projectile and an attachment parented to the part the mouse clicked for each projectile

Using AlignOrientation would allow the projectiles to rotate towards the target

Unfortunately it would take a very long time to make an example, so I recommend finding a tutorial that explains in detail how to use them

Okay, will do
Thanks for the help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.