So I am trying to make a simple FPS game. I made every other asset for the guns except recoil. For now, I'm trying to make a simple camera recoil script for when I shoot the gun.
However, when I shoot the gun, this pops up in output: 18:54:44.522 - Workspace.ProjectInfiniti.X38 SMG.Scripts.Gun Script:43: bad argument #1 (number expected, got Object)
which makes no sense because math.random(m,n) is a number right?
camera recoil function lines 38-59
function cameraRecoil(minX,maxX,minY,maxY)
camera.CameraType = Enum.CameraType.Scriptable
local oldCamCFrame = camera.CFrame
local recoilx = math.random(minX,maxX)
local recoily = math.random(minY,maxY)
for recoilUp = 1,5,1 do
camera.CFrame = camera.CFrame * CFrame.Angles(recoilx/5,recoily/5,0)
wait()
end
for recoilDown = 1,10,1 do
camera.CFrame = camera.CFrame * CFrame.Angles(-recoilx/10,-recoily/10,0)
wait()
end
camera.CameraType = Enum.CameraType.Fixed
end

1 comment
It must be an issue with your parameters.