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

Why is my wait not using the value I'm giving it?

Asked by 4 years ago

Issue

It's quite a simple question really.. for some reason, my wait won't grab my value, no matter what I do.

Script

        local WaitTimer = 0.2
        if Introduction then
            wait(WaitTimer)
            for Intro,Text in pairs (AnnounceMessages) do
                Announcer(Text)
            end
        end
0
How are you checking that it isn't waiting for that amount of time? User#34187 8 — 4y
0
By going through and testing the entire script, this is only a part of the script. Just2Terrify 566 — 4y
0
Consider adding a print statement after the wait to make sure that the code is actually reached. EncapsuIation 450 — 4y
0
It is reached, it just isn't waiting for the time it's supposed to be waiting for. Just2Terrify 566 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Wait is not completely accurate (by small portions of a millisecond) and it won't become more accurate as time goes by. These small waits will slowly add up to seconds or more. You could make your own wait tho (not always recommended).

local RenderStepped = game:GetService("RunService").RenderStepped
local function wait(t)
    t = t or 0
    local time = tick()
    while true do
        local Delta = RenderStepped:Wait()
        t = t + Delta
        if tick() - time >= t then
            break
        end
    end
end
Ad

Answer this question