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

What does RenderStepped:wait() do?

I remember seeing it in one of Friaza's tutorials, but I'm not quite sure what it does. I know that you can use RenderStepped to do something every 60th of a second, and you can use wait to pause the script for a 30th of a second. What does combining them do?

2 answers

✓ Accepted answer

RenderStepped

RenderStepped is an event of RunService. It's fired every frame render which is aproximately 1/60th of a second.


Wait

wait is a function that can wait down to aproximately 1/30th of a second.


Combining the two

When you use game:GetService('RunService').Renderstepped:wait() it makes RenderStepped redundant since the fastest the wait function can wait is apox 1/30th of a second. Just remove the wait() and have it in an event!.


Code

game:GetService('RunService').RenderStepped:connect(function()
	--code
end)

The above code would run every RenderStep, aprox 1/60th of a second.

1 comment

1

The function wait() is irrelevant to the method on the event

I don't really know what you mean by combining them, but RenderStepped can only be used in local scriptsand it's basically a wait(1/60), but without RenderStepped the least you can go to is wait(1/30), you should only use RenderStepped if you want to make something run as smooth as possible. For example moving a Textlabel locally.

Note: If you only write wait() without any number in the parameters that already defaults to wait(1/30)

local rs = game:GetService("RunService").RenderStepped

for i = 1, 20 do
	rs:wait()
	local text = script.Parent 
	text.Position = text.Position + UDim2.new(0,1,0,0)
end

That would make the gui move really smoothly as nearly as if it was tweening, if not already.

Hope this helps!

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