I recently wanted to fix up an aiming down sight script to my pleasure.I wanted it to where the player has to wait a little before UnAiming without it glitching so i tried to make up a debounce, i ended up coming up with this. It worked,But of course it came with a catch and that was that UnAims by itself. So i was wondering if someone could help me fix this to where it doesn't UnAim by itself? Here is the script.
local Tool = script.Parent aiming = false Tool.Equipped:connect(function(Mouse) Mouse.Button2Down:connect(function() if not aiming then aiming = true Tool.Aim.Value = 0.1 Tool.ZoomedIn.Value = true Tool.Parent.Humanoid.WalkSpeed = 10 Tool.GripPos = Vector3.new(0, 0.1, 0) wait(0.07) Tool.GripPos = Vector3.new(0.2,0,0) wait(0.07) Tool.GripPos = Vector3.new(0.4,-0.0,0) wait(0.07) Tool.GripPos = Vector3.new(0.6,-.1,0) wait(0.07) ---------------------------------------------- game.Workspace.CurrentCamera.FieldOfView = 70 game.Workspace.CurrentCamera.FieldOfView = 65 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 60 game.Workspace.CurrentCamera.FieldOfView = 55 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 50 game.Workspace.CurrentCamera.FieldOfView = 45 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 40 game.Workspace.CurrentCamera.FieldOfView = 35 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 30 wait(1) aiming = false if aiming == true then repeat wait() until aiming == false else do game.Workspace.CurrentCamera.FieldOfView = 30 game.Workspace.CurrentCamera.FieldOfView = 35 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 40 game.Workspace.CurrentCamera.FieldOfView = 45 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 50 game.Workspace.CurrentCamera.FieldOfView = 55 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 60 game.Workspace.CurrentCamera.FieldOfView = 65 wait(0.07) game.Workspace.CurrentCamera.FieldOfView = 70 ----------------------------------------------- Tool.ZoomedIn.Value = false Tool.Aim.Value = 15 Tool.Parent.Humanoid.WalkSpeed = 16 wait(0.07) Tool.GripPos = Vector3.new(0.6,-0.1,0) wait(0.07) Tool.GripPos = Vector3.new(0.4,0.0,0) wait(0.07) Tool.GripPos = Vector3.new(0.2,.0,0) wait(0.07) Tool.GripPos = Vector3.new(0, 0.1, 0) end end end end) end)