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

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

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

4 comments

0

How are you checking that it isn't waiting for that amount of time?

0

By going through and testing the entire script, this is only a part of the script.

0

Consider adding a print statement after the wait to make sure that the code is actually reached.

0

It is reached, it just isn't waiting for the time it's supposed to be waiting for.

1 answer

✓ Accepted answer

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

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