Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this really simple camera recoil script not work? [SOLVED]

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

0

It must be an issue with your parameters.

1 answer

whoops turns out i forgot to put .Value at the end of the NumberValues

thx Feahren

This discussion is preserved as it was. New answers, comments, and votes are closed.