(the error that appears at line 23 is bad argument #1 to '?' (Vector3 expected, got Object). I tried making the server submit mouse.Hit.p as mouse.Hit and the server has the mouse.p but the problem here is that the mouse would become the player with the error of p is not a valid object of player. help)answered by Winter Alien but 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)

1 comment
attempt to call a userdata value, what does this mean?