Error I get bad argument #2 to '?' (Vector3 expected, got number) 21:24:16.280 - Stack Begin
Error happens on line 4
function FireLaser(mouse, count) local aimPos = mouse.hit.p local bulletOrigin = BulletOrigin.Position local distance = bulletOrigin - aimPos.magnitude if Recoil < MaxRecoil then Recoil = Recoil + 5 end for i = 1, count do local aimWithSpread = Vector3.new(aimPos.x + math.random(-(BulletSpread / 10) * distance, BulletSpread / 10 * distance), aimPos.y + math.random(-(BulletSpread / 10) * distance, BulletSpread / 10 * distance), aimPos.z + math.random(-(BulletSpread / 10) * distance, BulletSpread / 10 * distance)) local collision, collisionPos = CreateRaycast(player.Character.Head.Position, aimWithSpread, { player.Character, Camera, workspace.BulletDump, game.ReplicatedStorage })
You cannot add or subtract a Vector3 by a scalar, I assume what you meant to do is:
local distance = (bulletOrigin - aimPos).magnitude --Parentheses are very important!
Which would indeed return the distance between the two vectors.