Help with FPS recoil!

In my fps game I have a simple recoil script but I would like to to also randomly move the camera side to side, my problem is that it wont accept numbers under 1 any help?

game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(0.01, math.random(-0.1,0.1), 0.01)
1 Like

Try this:

workspace.CurrentCamera.CFrame *= CFrame.Angles(0.01, Random.new():NextNumber(-0.1, 0.1), 0.01)

Have you tried using math.rad() for numbers that aren’t 0 in CFrame.Angles()? You’d likely have to increase 0.01 to something else. Though. Take this for example:

workspace.CurrentCamera.CFrame *= CFrame.Angles(math.rad(10), math.rad(math.random(-10, 10)), math.rad(10))

still cant go under 1 jhjhjhjhjhjjh

You want a 0.1° recoil? Quite unusual. Not sure if it’ll work, however, as I haven’t gone below 2°. There is nothing in documentation that i can find that says you can’t go under 1° tho…

if i put -0.1,0.1 it doesent work

Using math.random() with no arguments returns a random number between 0 and 1 with lots of precision. Therefore, if you want to have randomization go smaller, you can do something like this: math.random()*.2-.1
This number picks a random number between 0 and 0.2 with higher precision, and subtracks 0.1 so the number is between -0.1 and 0.1.

FYI: math.random(a,b) is supposed to use arguments a and b as integers, not a number.

Not sure why that doesn’t work. However, you’ll find that a 0.1° just isn’t sufficient for recoil.

0.9 doesent even work either? gfggfgf

All I can do is recommend 1° or above.