2D tank does not fire correctly

I’m attempting to create a 2D tank game but ran into am currently lost at bullet firing. The bullets are supposed to shoot from the “ShootPart” and move into the canvas called “Bullets” which is scaled to cover the entire canvas. The issue is the bullets do not spawn directly at the shoot part, spawning around 100 pixels above it.

Important notes:

  • The canvas will be moving with the player
  • The bullets should not stop at the players mouse, but continue going in the direction they were shot from linearly

Any help is appreciated.


image

Client script:

--<< NotFrindow >>--

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

local interface = script.Parent.Interface
local canvas = interface.Canvas
local tank = canvas.Players.PlayerTemplate

local remotes = game:GetService("ReplicatedStorage").Remotes

mouse.Move:Connect(function()
	local rs = game:GetService("RunService")
	local difference = (Vector2.new(mouse.X, mouse.Y) - tank.AbsolutePosition)
	tank.Rotation = -math.deg(math.atan2(-difference.X, -difference.Y))
	remotes.UpdatePosition:FireServer(
		{
			["Position"] = tank.Position,
			["Rotation"] = tank.Rotation
		}
	)
	print(mouse.X)
	print(mouse.Y)
end)

mouse.Button1Down:Connect(function()
	local newBullet = tank.Barrel.ShootPart.Bullet:Clone()
	newBullet.Parent = canvas.Bullets
	newBullet.Position = UDim2.new(0, tank.Barrel.ShootPart.AbsolutePosition.X, 0, tank.Barrel.ShootPart.AbsolutePosition.Y)
	newBullet:TweenPosition(
		UDim2.new(0, mouse.X, 0, mouse.Y)
	)
end)