You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am creating recoil.
What is the issue? Include screenshots / videos if possible!
When I shoot the gun, and the recoil function fires, it snaps my camera instead of making my camera go up
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried, but none of the recoil were helpful.
I want a basic recoil that moves the cameras orientation up by the settings recoil value.
local function recoil()
local Camera = game.Workspace.CurrentCamera
local r = Camera.CFrame.Rotation
Camera.CFrame = CFrame.Angles(r.X,r.Y+Config.Recoil.Value,r.Z)
end
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local RECOIL_AMOUNT = 1
local function recoil()
camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(RECOIL_AMOUNT), 0, 0)
end
Try this perhaps? Sorry, I’m not the best with cframes so I cant really explain why yours wasn’t working. However, testing this code in my own place made the camera rotate “upwards” every time the function was called. Use lerping to smooth it out.