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

My script is slow. How could i make it faster?

Asked by 11 years ago

Hello. My script is slow!

01q=true
02script.Parent.MouseButton1Click:connect(function()
03    if q then
04        q=false
05 
06        for i=50,250,0.1 do game:GetService("RunService").RenderStepped:wait()
07            script.Parent.Parent.Position = UDim2.new(1, -(i), 0, 500)
08        end
09 
10        q=true
11    end
12end)

It`s at a rate of 30/s

It`s made for making an animation...

I`ll upload the .gif later.

2 answers

Log in to vote
3
Answered by 11 years ago

It would be much simpler to use the TweenPosition method on the GUI. Like this:

1script.Parent.Parent:TweenPosition(
2    UDim2.new(1, -250, 0, 500), --Replace this with where you want the GUI to be
3    "Out", --Replace this with the direction of the tween
4    "Linear", --Replace this with the style of the tween
5    10 --Replace this with the duration of the tween
6)

It's much easier! Hope this helped!

Note: For more information on TweenPosition, click here: TweenPosition

0
Thank, you =D FieryEvent 185 — 11y
Ad
Log in to vote
-1
Answered by 11 years ago

Put a Wait(). I'm sure it'll help.

0
But the wait() function goes down to 14/s rate! FieryEvent 185 — 11y

Answer this question