You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
So I made a projectile that uses a mouseRay using MouseLocation
What is the issue? Include screenshots / videos if possible!
the problem is that, the part is not going where it is intended to go to, it should go towards the npc but goes to the camera
as you can see, the part is going towards the camera, it should go to the npc instead, which is not what I want
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
First I tried using a subtracting head to mouse so it cannot be shot by a player that is facing the other way, but it didn’t work, I tried this
local headPosition = game.Players.LocalPlayer.Character.Head.CFrame.lookVector
local mouseLookCFrame = CFrame.new(game.Players.LocalPlayer.Character.Head.Position - mouse.Hit.p).LookVector
local mouseToHeadDistance = (headPosition - mouseLookCFrame).Magnitude
if mouseToHeadDistance < 1.3 then
-- My code
end
then I tried using dev hub but nothing worked, I try to tween the part to the position
also
you might set target filter of the mouse to workspace and add touched event to it or anything possible
because if the plr moves away from the targeted pos of the bullet it will just stop there without hitting anything