I am making a gun script and this local script I am showing below fires the remote event to create a recast. When I fire the gun I also change the camera frame by multiplying it to make recoil. The recoil is rather smooth but I want the camera to naturally come down after firing. I decided to divide by the same number after each camera movement but for some reason it says that it attempted division in red and doesn’t work. I am new to scripting so if I am making a simple mistake I won’t be surprised.
local RunService:RunService = game:GetService("RunService")
local Players:Players = game:GetService("Players")
local Player = Players.LocalPlayer
local char = script.Parent.Parent
local Mouse = Player:GetMouse()
local Tool:Tool = script.Parent
local RemoteEvent:RemoteEvent = script.Parent.RemoteEvent
local Holdable,Holding = true,false
function Send()
RemoteEvent:FireServer({Position = Mouse.Hit.Position})
end
Tool.Activated:Connect(function()
Holding = true
if Holdable then
local Run
Run = RunService.Heartbeat:Connect(function()
if not Holding then
Run:Disconnect()
end
Send()
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(1.1),0,0)
wait(0.01)
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame / CFrame.Angles(math.rad(1.1),0,0)
end)
else
Send()
end
end)
Tool.Deactivated:Connect(function()
Holding = false
end)
Tool.Unequipped:Connect(function()
Holding = false
end)