Gun using raycast

Im a bit rusty on raycasts and ive been trying to make a gun with raycast, when i click the beam goes nowere near where i clicked it like a random position…

this is the server and ive been using a remote function to get the mouse position

local tool = script.Parent
tool.Activated:Connect(function()
	local start = script.Parent.Handle.StartPos.WorldPosition
	local hit = game:GetService("ReplicatedStorage").GetMouse:InvokeClient(game.Players:GetPlayerFromCharacter(script.Parent.Parent))
	local rayres = workspace:Raycast(start,(hit - start).Unit * 350)
	if rayres then
		local newatt = Instance.new("Attachment")
		newatt.Parent = rayres.Instance
		newatt.Position = hit
		script.Parent.Beam.Attachment1 = newatt
	end
end)

image
(the end is where the mouse position should be)