# Help with ranged weapon

So I am currently making a weapon system(Like guns) and there are two things im stuck on.

1. How can I create recoil, I feel like just changing the cameras offset doesnt look all that great.
1. How can I create spread. To currently make my bullets face the right direction(Yes I am using a part as a bullet) I use CFrame.Lookat(Bullet.Position,Target.Position), I’m unsure on how I can change it to face pretty much the same direction but off by a little its been troubling me for some reason.
1. Are there any weapon kits or something out there already that I could look at? I feel like it might help being able to see how its done
4 Likes
1. you can lerp the camera position
2. use upvector and rightvector, for example:
``````targetPosition = targetPosition + (torso.upvector * math.random(-spread, spread) + (torso.rightvector * math.random(-spread,spread))
``````

(R41NB0W’s solution for spread is much simpler however it will cause you to miss bullets randomly since the spread also applies to forward and backward, while mine only applies to up and down, left and right)
3. ACS

1 Like

Probs not the best solution 4 spread, but like u could get the target position, create a loop that offsets it by a little bit for each bullet and then faces a bullet towards the new position :3

``````--like this....
local position = Target.Position
for _ = 1,amountofbullets do
local bullet = Cloned bullet possibly maybe
local randomPos = position + Vector3.new(math.random(-3,3),(math.random(-3,3),(math.random(-3,3))
bullet.CFrame = CFrame.lookAt(bullet.Position,Target.Position)
end``````

Ahh yes that was the problem I had originally! Thank you! Where can I see the ACS? I’ve heard about it

just search it up in the toolbox models tab, you should be able to find it there

1 Like

Hmm I might have done it wrong with the spread, heres my code. Rn it just acts if it didnt have spread yk yk.

``````           local spread = mod.Stuff.SpreadMax
local targetPosition = module.GetPoInfrontOfCFrame(800,CamCFrame)

bullet.CFrame = CFrame.lookAt(bullet.Position,module.GetPoInfrontOfCFrame(800,CamCFrame))
``````

hmm that looks fine to me, try printing the targetPosition before and after you add the spread

Wait I forgot to apply the targetPosition! let me go do that!
Hmm thats weird. Even after making it use the target position same thing. Ill try printing.

Ok edit.
It does print and the position is different every time but its still firing in the same direction everytime!

perhaps it has to do something with your module?

Ill try just providing it with numbers that I can guarantee are there

Hmm same thing. Ill try running more tests tomorrow