So, I am trying to make a pistol on which you can aim down sights. I tried tinkering with the CurrentCamera to try to do that, but I didn't get the results I wanted. Can someone help me with this?
Code:
mouse.Button2Down:connect(function() print("Aiming down sights!") if not ads then cam.CameraSubject = gun.Union cam.CFrame = gun.Union.CFrame ads = true else cam.CameraSubject = plr.Character.Humanoid cam.CFrame = plr.Character.HumanoidRootPart.CFrame ads = false end end)
The problem with your code is that you’re using the KeyDown event which is deprecated, and you’re using the connect method when it’s Connect.
gun.Equipped:Connect(function(mouse) mouse.Button2Down:Connect(function() if not ads then cam.FieldOfView = 10 cam.CameraSubject = gun.Union cam.CFrame = gun.Union.CFrame ads = true else cam.CameraSubject = plr.Character.Humanoid cam.CFrame = plr.Character.HumanoidRootPart.CFrame ads = false end end) game:GetService("ContextActionService"):BindAction( -- use this instead of keydown. "Reload", reload, true, Enum.KeyCode.R ) end)