Hello. Recently I’ve been having fun with making guns in Roblox Studio. However I can’t think of a way to make a working (smooth) recoil system.
At first I made a working recoil system. Everytime I shoot I multiplied the Camera CFrame by Cframe.Angles, which would look like this.
Camera.CFrame *= CFrame.Angles(math.rad(3), 0, 0)
This gave me a choppy recoil, though, so then I tried TweenService. That didn’t work either, because when I move the camera doesn’t follow my character.
Tried Lerping the camera too, but since I fire my shots in a ‘RenderStepped’ event, the code below the function does not run, leaving me with no debounce and no way to have a cooldown.
RS.Stepped:Connect(function(dt)
if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and not debounce then
local MousePos = Mouse.Hit.Position
Event:FireServer(MousePos, Camera.CFrame.Position)
lerp()
debounce = true
wait(waitTime)
debounce = false
end
end)
This is my lerp function:
function lerp()
local Goal = Camera.CFrame * CFrame.Angles(math.rad(3), 0, 0)
for increment = 0, 1, .01 do
wait()
Camera.CFrame:Lerp(Goal, increment)
end
end
I also read about Spring Modules, but that’s wayyy too complicated for my scripting knowledge( unless you just give me the code , jk)
So, do you guys have any other ideas for making a Smooth Recoil System? If so, please help me out.