I've made a sprinting script when you press 'q', you sprint. Your camera also zooms out a little. But when you rapidly press 'q' the camera looks bad. How would i go about making it look smother?
here is the script:
mouse = game.Players.LocalPlayer:GetMouse() mouse.KeyDown:connect(function(key) if key == "q" then script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,true) script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,false) wait() script.Parent.BackgroundColor3 = Color3.new(0,0,1) if game.Workspace.CurrentCamera.FieldOfView ~= 80 then for i = 70,80,1 do game:GetService("RunService").RenderStepped:wait() game.Workspace.CurrentCamera.FieldOfView = i end end end end) mouse.KeyUp:connect(function(key) if key == "q" then script.Parent.BackgroundColor3 = Color3.new(0,1,0) script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,true) script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,false) if game.Workspace.CurrentCamera.FieldOfView ~= 70 then for i = 80,70,-1 do game:GetService("RunService").RenderStepped:wait() game.Workspace.CurrentCamera.FieldOfView = i end end end end)
here is the game so you see what it looks like:
You could set a debounce that does not allow the function to fire if in the middle of firing.
Example:
mouse = game.Players.LocalPlayer:GetMouse() local firing=false mouse.KeyDown:connect(function(key) if key == "q" then if not firing then firing=true script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,true) script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,false) wait() script.Parent.BackgroundColor3 = Color3.new(0,0,1) if game.Workspace.CurrentCamera.FieldOfView ~= 80 then for i = 70,80,1 do game:GetService("RunService").RenderStepped:wait() game.Workspace.CurrentCamera.FieldOfView = i end end firing=false end end end) mouse.KeyUp:connect(function(key) if key == "q" then if not firing then firing=true script.Parent.BackgroundColor3 = Color3.new(0,1,0) script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,true) script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,false) if game.Workspace.CurrentCamera.FieldOfView ~= 70 then for i = 80,70,-1 do game:GetService("RunService").RenderStepped:wait() game.Workspace.CurrentCamera.FieldOfView = i end end firing=false end end end)
Click here for more information on 'debounce'