The first video linked shows my gun system, and what happens when I try to use CFrame.Angles() to rotate my gun. The second video is a reference of what I want my system to look like
Here is my script:
local Offset = Vector3.new(math.rad(0), math.rad(0), math.rad(0))
local currentX = mouse.X
local currentY = mouse.Y
local X = 0
local Y = 0
local sens = 10
mouse.Move:Connect(function()
X = math.clamp(X - math.rad(cam.CFrame.LookVector.X - currentX) * sens, -0.25, 0.25)
Y = math.clamp(Y - math.rad(cam.CFrame.LookVector.Y - currentY) * sens, -0.25, 0.25)
Offset = Vector3.new(X, Y, 0)
currentX = cam.CFrame.LookVector.X
currentY = cam.CFrame.LookVector.Y
end)
run.RenderStepped:Connect(function()
gun:SetPrimaryPartCFrame(cam.CFrame * CFrame.Angles(Offset.Y, Offset.X, Offset.Z))
end)
(I am aware that the Y offset comes first in my CFrame.Angles, this is intentional because the gun was not rotating in the proper direction)