Is there a similar service or a line of code that functions opposite to Debris?

I’m creating a script that adds a stat to a player after a certain amount of time, I could use wait() but I’m concerned it’s unreliable so I’m wondering if there is any other alternatives.

Script
script.Parent.MouseButton1Click:Connect(function()
	if PreviewMode == true then
		script.Parent.UploadText.Text = "Preview"
		local String = script.Parent.Parent.Parent.IDInput.Text
		local InputType = tonumber(String)
		local Length = #String
		if InputType ~= nil and Length == 10 then
			PreviewMode = false
			Preview.Visible = true
			Preview.Image = "rbxassetid://2300836745"
			Preview:TweenSize(UDim2.new(0.951, 0,0.013, 0))
			Preview:TweenPosition(UDim2.new(0.501, 0,0.177, 0))
			wait(1)
			CTween:Play()
			wait(.5)
			Preview:TweenSize(UDim2.new(0.951, 0,0.8, 0))
			Preview:TweenPosition(UDim2.new(0.501, 0,0.57, 0))
			BTween:Play()
			wait(1)
			Preview.Image = "rbxassetid://"..String
			script.Parent.UploadText.Text = "  Upload  "
		end
	else
		--wait 3 seconds
		--give stat
	end
end)

If you don’t really care about the wait(3) being 100% exact, then it’s not an issue to use wait(3) as far as I know. The issue with wait(n) is using it without n, for example in a loop.
If you want 100% exact results, you can use a library like Promise https://eryn.io/roblox-lua-promise/lib/Installation.html and use it’s delay function (https://eryn.io/roblox-lua-promise/lib/#delay). It basically can do what you want to do, wait 3 seconds and then run the piece of code.

Ok I’ll try this out thank you!

Also, if you want functions to happen synchronously, I suggest using delay().

Perhaps what you’re looking for is the delay global.
Here’s a blog introducing you to it from way back in 2007: Roblox Blog - All the latest news direct from Roblox employees.

Thus, your code would look like this:

script.Parent.MouseButton1Click:Connect(function()
	if PreviewMode == true then
		script.Parent.UploadText.Text = "Preview"
		local String = script.Parent.Parent.Parent.IDInput.Text
		local InputType = tonumber(String)
		local Length = #String
		if InputType ~= nil and Length == 10 then
			PreviewMode = false
			Preview.Visible = true
			Preview.Image = "rbxassetid://2300836745"
			Preview:TweenSize(UDim2.new(0.951, 0,0.013, 0))
			Preview:TweenPosition(UDim2.new(0.501, 0,0.177, 0))
			wait(1)
			CTween:Play()
			wait(.5)
			Preview:TweenSize(UDim2.new(0.951, 0,0.8, 0))
			Preview:TweenPosition(UDim2.new(0.501, 0,0.57, 0))
			BTween:Play()
			wait(1)
			Preview.Image = "rbxassetid://"..String
			script.Parent.UploadText.Text = "  Upload  "
		end
	else
		delay(3, function()
		    --give stat
                end)

	end
end)

It’s worth noting it doesn’t yield!

Hope this helps :smiley: