Projectile weapon system not accurate

I’ve been trying to make a projectile weapon system using raycasts and tweenservice, however my projectile is always a little offset from the mouse.
robloxapp-20230912-1243463.wmv (700.7 KB)

Here’s my code:

local Tool = script.Parent
local Mouse = Player:GetMouse()
	local Origin = Tool:FindFirstChild('Handle')
	local RayParams =
	RayParams.FilterDescendantsInstances= {Player.Character}
	RayParams.FilterType = Enum.RaycastFilterType.Exclude
	local RaycastResult = workspace:Raycast(Origin.Position, Mouse.UnitRay.Direction * 100, RayParams)
	if RaycastResult then
		local BulletClone = Bullet:Clone()
		BulletClone.CFrame =,  Mouse.UnitRay.Direction * 100)
		BulletClone.Parent = workspace
		local RayTween = TweenService:Create(BulletClone, tweenInfo, {Position = RaycastResult.Position})

Instead of using Mouse.UnitRay.Direction, try doing the following instead:

local range = 999 -- It's the range of the weapon. Duh.
local mousePos = Mouse:GetPosition()
local direction = (mousePos - character.Head.Position).Unit * range

That’s the kind of function I use for my weapon scripts. Replace Mouse.UnitRy.Direction with the new Direction, and it should work.
If it doens’t work, ping me again and I’ll pull up my actual code.

1 Like

mouse:GetPosition() doesn’t work, can mouse.Hit.Position work in it’s place?

1 Like

Yes, sorry. Mouse.Hit.Position is correct.

1 Like