Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Thank, you =D

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

1 comment

0

But the wait() function goes down to 14/s rate!

This discussion is preserved as it was. New answers, comments, and votes are closed.