Player mouse issues

I’m attempting to recreate a mobile called Blast Ball. There is a cannon in a 2d view that you control to shoot little balls at other big balls.

I’m using the mouse to control where the part (Soon will be the cannon) is. But it seemed very far off from the xpos of the mouse ( As its 2d ) so i tried messing with the numbers to divide the xpos and its a little bit closer.

The Issue
In some places its just slightly behind or ahead of where the mouse should be. Is there a way to fix this or am i just doing it a wrong way?

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

rs.RenderStepped:Connect(function()
	local xpos = mouse.X
	local newcframe = CFrame.new(xpos/25,0,5)
	game.Workspace:WaitForChild("Part").CFrame = newcframe:Inverse()
end)

The script is in the local player, the server will be only 1 player servers so i dont need to effect the server just the client ( if your wondering why no remote events)

A video following to show:

https://gyazo.com/78d6951a7a367a65ee279f63babc5cb3

You can do Mouse.Hit.P to get the position in the world based on where the mouse is or just Mouse.Hit for the CFrame.

1 Like

How do I fix the issue of if the mouse hits the sky it just goes flying away?