Soo I made a gun system. Problem is that even if it does work, the recoil system does not work (it should move the camera, like in Arsenal).
I looked in the forums for any help, I know that we should update camera’s CFrame every RunService.Stepped but the posts dedicated about it is about a third part that rotates and the OP wanted to copy it’s angle for a recoil.
I don’t know how to do it, plz help
Code :
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local shootEvent = game.ReplicatedStorage:WaitForChild("ShootEvent")
local camera = game.Workspace.CurrentCamera
local debounce = false
local mouseHolding = false
mouse.Button1Down:Connect(function()
mouseHolding = true
end)
mouse.Button1Up:Connect(function()
mouseHolding = false
end)
while task.wait() do
if mouseHolding then -- Check if the player is holding the mouse
if player.Character then
if player.Character:FindFirstChildOfClass("Tool") then -- Check if there's a tool
local tool = player.Character:FindFirstChildOfClass("Tool")
if tool:FindFirstChild("ShootPart") and tool:FindFirstChild("Configuration") then -- Check if the tool is a gun
local configuration = tool.Configuration
local recoil = configuration.Recoil
local cooldown = configuration.Cooldown
if not debounce then
debounce = true
shootEvent:FireServer(mouse.Hit.Position, mouse.Target) -- Actually firing the gun
camera.CFrame *= CFrame.Angles(math.rad(recoil.Value), 0, 0) -- Recoil 👈
task.wait(cooldown.Value)
debounce = false
end
end
end
end
end
end
-- What it does is check if player is holding the mouse. Then it will fire (without stopping if you're holding the mouse)
-- and do a recoil