Raycast ignoring most objects that are not directly in workspace

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to raycast in the direction of a player’s mouse
  2. What is the issue? Include screenshots / videos if possible!
    The raycast does not go in the direction of the player’s mouse and redirects itself to the nearest object in workspace.
local lt = require(script.Parent.GameFunctions)

function shot(plr,pos,team)
	local beam = script.Parent.otherstuff.effects.Beam:Clone()
	local particle = script.Parent.otherstuff.effects.ParticleEmitter:Clone()
	local barrel = game.Workspace:FindFirstChild(plr.Name)["Laser Gun"].Handle.Part
	local dir =  pos - barrel.Position 
	local rayParam = RaycastParams.new()
	local hb = script.Parent.otherstuff.hitboxes.networkcomp:Clone()
	hb.creator.Value = plr
	hb.active.Value = true
	hb.Parent = game.Workspace
	rayParam.FilterDescendantsInstances = {workspace.LazerTagAssets, barrel.Parent.Parent, plr.Character}
	rayParam.FilterType = Enum.RaycastFilterType.Blacklist
	rayParam.CollisionGroup = "Default"
	rayParam.IgnoreWater = false
	local ray = workspace:Raycast(barrel.Position, dir.Unit*1000, rayParam)
	
	print("remote")
	if ray then
		print("loltest")
		local hitins = ray.Instance
		local hitpos = ray.Position
		hb.Position = hitpos
		beam.Parent = barrel
		local hitatt = Instance.new("Attachment")
		hitatt.Parent = hitins
		hitatt.WorldPosition = hitpos
		beam.Attachment0 = barrel.Attachment
		beam.Attachment1 = hitatt
		particle.Parent = hitatt
		if team == "o" then
			beam.Color = ColorSequence.new(Color3.new(1, 0.545098, 0.145098))
			particle.Color = ColorSequence.new(Color3.new(1, 0.545098, 0.145098))
			hb.Color = Color3.new(1, 0.545098, 0.145098)
		elseif team == "g" then
			beam.Color = ColorSequence.new(Color3.new(0, 1, 0))
			particle.Color = ColorSequence.new(Color3.new(0, 1, 0))
			hb.Color = Color3.new(0, 1, 0)
		end
		beam.Enabled = true
		particle.Enabled = true
		print("shot : " .. hitins.Name)
		if hitins.Parent:FindFirstChild("Humanoid") then
			local hitplr = game.Players:FindFirstChild(hitins.Parent.Name)
			lt.respawn(hitplr)
			lt.addpoints(game.Workspace.LazerTagAssets.values.scores:FindFirstChild(plr.Name), 1)
		end
		wait(0.1)	
		hitatt:Destroy()
		particle:Destroy()
		beam:Destroy()
		hb:Destroy()
	else
		hb:Destroy()
	end
end

game.ReplicatedStorage.FireLaser.OnServerEvent:Connect(shot)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Commenting because this issue is still going over my head