Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a way to make this more smooth?

Asked by 10 years ago

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:

01mouse = game.Players.LocalPlayer:GetMouse()
02 
03mouse.KeyDown:connect(function(key)
04    if key == "q" then
05        script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,true)
06        script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,false)
07        wait()
08        script.Parent.BackgroundColor3 = Color3.new(0,0,1)
09        if game.Workspace.CurrentCamera.FieldOfView ~= 80 then
10        for i = 70,80,1 do
11                game:GetService("RunService").RenderStepped:wait()
12                game.Workspace.CurrentCamera.FieldOfView = i
13            end
14        end
15    end
View all 30 lines...

here is the game so you see what it looks like:

http://www.roblox.com/games/197480972/---

0
The Sprint is amazing. The people who keep pressing Q are just noobs who want unlimited sprint. It's good as is. Keep it up, and oh, I like that counter that keeps going up the higher you get. GreekGodOfMLG 244 — 10y
0
Thanks! Senor_Chung 210 — 10y

1 answer

Log in to vote
0
Answered by
Muoshuu 580 Moderation Voter
10 years ago

You could set a debounce that does not allow the function to fire if in the middle of firing.

Example:

01mouse = game.Players.LocalPlayer:GetMouse()
02local firing=false
03 
04mouse.KeyDown:connect(function(key)
05    if key == "q" then
06        if not firing then
07            firing=true
08            script.Parent:TweenSize(UDim2.new(0,100,0,50),"InOut","Quad",2,true)
09            script.Parent:TweenSize(UDim2.new(1,100,0,50),"InOut","Quad",6,false)
10            wait()
11            script.Parent.BackgroundColor3 = Color3.new(0,0,1)
12            if game.Workspace.CurrentCamera.FieldOfView ~= 80 then
13                for i = 70,80,1 do
14                    game:GetService("RunService").RenderStepped:wait()
15                    game.Workspace.CurrentCamera.FieldOfView = i
View all 39 lines...

Click here for more information on 'debounce'

Ad

Answer this question