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 10 years ago

Hello. My script is slow!

q=true
script.Parent.MouseButton1Click:connect(function()
    if q then
        q=false

        for i=50,250,0.1 do game:GetService("RunService").RenderStepped:wait()
            script.Parent.Parent.Position = UDim2.new(1, -(i), 0, 500)
        end

        q=true
    end
end)

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 10 years ago

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

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

It's much easier! Hope this helped!

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

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

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

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

Answer this question