Code not executing with a big wait like wait(512)

Hello! I tried making a self destruct script and put wait(512), and I tested then waited 512 seconds and nothing happened. I tried going to google, developer hub, and there was nothing. So I changed 512 to 10 seconds then tested and it worked. Is there a limit on how many seconds you can put with wait()?

here is what the code looked like:

	local alert = game.ServerStorage.emergency:Clone()
	local siren = game.ServerStorage.siren:Clone()
	siren.Parent = workspace
	siren.Playing = true
	alert.Parent = workspace
	alert.Looped = true
	wait(24)
	alert.Playing = true
wait(526)
	local D = game.ServerStorage.DV:Clone()
	local air = game.ServerStorage.air:Clone()
	D.Parent = workspace
	air.Parent = workspace
	D.Playing = true
	air.Playing = true

this is the solution I tried:Screenshot_144

The reason I’m trying to do this is because I am trying to make a ESDS (emergency self destruct sequence) where there is a 5 minute warning countdown before detonation.

sorry if this is idiotic, I’m a bit new to LuaU scripting

1 Like
local alert = game.ServerStorage.emergency:Clone()
local siren = game.ServerStorage.siren:Clone()
siren.Parent = workspace
siren.Playing = true
alert.Parent = workspace
alert.Looped = true
wait(24)
alert.Playing = true
for i = 526,0,-1 do
	print(i)
	wait(1)
end
local D = game.ServerStorage.DV:Clone()
local air = game.ServerStorage.air:Clone()
D.Parent = workspace
air.Parent = workspace
D.Playing = true
air.Playing = true

Now you’ll be able to tell if your time is up, because it will print what the time is in the console.

2 Likes

You can use the new Task library, and use task.delay() (which is a replacement to delay())

Syntax looks like this:

‘’’
task.delay(512, function()
— do your stuff here
end)
‘’’

2 Likes

Generally wait is not a good option anymore. The new task library has a replacement, you should instead use task.wait(), it has the same parameters as wait() but it is more reliable.
Like @RecanValor mentioned you can also use task.delay to schedule it to run later.

You should read the post about the new library!

2 Likes

Oh okay Thanks! I’ll try that.

Okay. Thanks for the help! I’ll try that now.