Im getting an error on this certain part on my code and im very confused im currently making a gun system and keep getting this error when I shoot a dummy.
Error:
Argument 1 missing or nil
Stack Begin
Script ‘Players.jake_4543.PlayerGui.Client.Modules.Framework’, Line 237
Stack End
FRAMEWORK:
function gun.Shoot(weapon)
if debounce == false then
debounce = true
local muzzlePos = weapon.Main:WaitForChild("Muzzle").Position
local wm = require(weaponModules:FindFirstChild(weapon.Name))
local velocity = weapon.Main.Eject.CFrame.LookVector * 20 + Vector3.new(0,30,0)
local ejectPos = weapon.Main.Eject.Position
local ejectOr = weapon.Main.BulletOrientation.Orientation
spawn(function()
if muzzlePos then
rayCastInfo = script.Parent.Parent.Parent.Server.Events.Fire:InvokeServer(muzzlePos,mouse.Hit.p,weapon.Name,{["Vel"] = velocity,["Pos"] = ejectPos,["Or"] = ejectOr}) --Line where its erroring
else
rayCastInfo = true
end
end)
--spawn(function()
repeat wait() until rayCastInfo ~= nil
if rayCastInfo ~= true then
spawn(function()
gun.Bolt(weapon)
gun.Recoil(weapon)
end)
local dam = rayCastInfo["Damage"]
local hpp = rayCastInfo["HitPart"]
local isHumanoid = rayCastInfo["IsHumanoid"]
local isDead = rayCastInfo["IsDead"]
if isHumanoid == true and isDead == false then
if dam and hpp then
print(dam)
end
end
end
--end)
wait(60/wm.RateOfFire)
debounce = false
end
end
SERVER:
script.Parent.Events.Fire.OnServerInvoke = function(player,from,to,weaponName,bulletCaseTable)
local it = nil
if player.Name == script.Parent.Parent.Parent.Name then
local wm = require(gunModules:FindFirstChild(weaponName))
if (player.Character.HumanoidRootPart.Position - from).Magnitude <= (wm.GunLength * 5) then
if shootDebounce == false then
shootDebounce = true
ejectCase(wm,bulletCaseTable.Vel,bulletCaseTable.Pos,bulletCaseTable.Or)
spawn(function()
createFireSound(player,weaponName)
end)
local infoTable = raycastModule.Raycast(from,to,1,"-"..wm.Spread,wm.Spread,player,weaponName)
it = infoTable
wait(60/wm.RateOfFire)
shootDebounce = false
else
return true
end
else
player:Kick("Possible exploiter. If this persists report to game owner.")
end
else
player:Kick("Possible exploiter. If this persists report to game owner.")
end
return it
end
Any help would be appreciated.