Hello, im making a grappling gun with a raycast gun, but for some reason it rotates the whole map. Can someone help me fix it?

local tool = script.Parent
local user
 
tool.Equipped:connect(function(mouse)
    user = tool.Parent 

 
    mouse.Button1Down:connect(function() 
        local ray = Ray.new(tool.Barrel.CFrame.p, (mouse.Hit.p - tool.Barrel.CFrame.p).unit*300)
        local hit, position = game.Workspace:FindPartOnRay(ray, user)
		script.Parent.Handle.Fire:Play()
        local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
        if humanoid then
            humanoid:TakeDamage(15)
        end
        local distance = (position - tool.Barrel.CFrame.p).magnitude
        local rayPart = Instance.new("Part", user)
        rayPart.Name          = "RayPart"
        rayPart.BrickColor    = BrickColor.new("White")
		rayPart.Material	  = "SmoothPlastic"
        rayPart.Transparency  = 0
        rayPart.Anchored      = false
        rayPart.CanCollide    = false
        rayPart.TopSurface    = Enum.SurfaceType.Smooth
        rayPart.BottomSurface = Enum.SurfaceType.Smooth
        rayPart.formFactor    = Enum.FormFactor.Custom
        rayPart.Size          = Vector3.new(0.2, 0.2, distance)
		rayPart.CFrame        = CFrame.new(position, tool.Barrel.CFrame.p) * CFrame.new(0, 0, -distance/2)
		rayPart.Touched:Connect(function(touch)
			if touch.ClassName == "Part" then
				local weld = Instance.new("WeldConstraint", rayPart)
				weld.Part0 = touch
				weld.Part1 = rayPart
			end
		end)
		mouse.Button1Up:connect(function()
			rayPart:Destroy()
		end)
    end)
end)