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

What does RenderStepped:wait() do?

Asked by
funyun 958 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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
The function wait() is irrelevant to the method on the event BlueTaslem 18071 — 8y
Ad
Log in to vote
3
Answered by 8 years ago

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!

Answer this question