when i click it , nothing happens and this error occurs. attempt to call a userdata value

Local Script

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
--Variables
 local spread = .2
local Ammo = 60
local MaxAmmo =60
local Mag =360
local automatic = true
local enabled = true
local Hold = true
local reloading = false
local range = 100
--Variables
local mouse = nil
function hold()
    Hold = true
    while Hold and enabled and player.Character.Humanoid.Health > 0 and Ammo > 0 and reloading == false and tool.Enabled == true do
                if hold == false then break end
                enabled = false
                tool.FireWeapon:FireServer(mouse.Hit.p)
                --fireserverhere
                wait(firerate)
        enabled = true  
        if automatic == false then
            enabled = true
            break   
        end
    end
    function holddown()
    Hold = false
end
tool.Equipped:connect(function(Mouse)
    mouse = Mouse
    tool.Enabled = true
    mouse.Button1Down:connect(hold)
mouse.Button1Up:connect(holddown)
end)

The line that errors in server script

local range = 100
function shoot(player, mouse)
local ray = Ray.new(tool.Handle.CFrame.p, (mouse - tool.Handle.CFrame.p).unit * range)
--Useless code
end
tool.FireWeapon.OnServerEvent:connect(player, shoot)