How would I script this function?

So I have thought of a system for my game but for it I need for it when a player plays the game for x amount of time then a function is called, I am unsure on how to do this so help is appreciated!

Thank you in advance kiddies!

1 Like

If you have some code to show then that would help. If not, you could use a wait() function to simply wait the amount of time you need.

1 Like

I just realised how simple it is to script thanks for the help :3 !

1 Like

No problem! :slight_smile:

Might I add: the wait() function will Yield the code, so any code under it will not run until the wait is finished. So, if you want to have the code running, and the wait to run after a set amount of time, you could use:

spawn(function()
	wait(60) -- 60 being how many seconds
end)

As a spawn(f) function runs simultaneously along with the rest of the code in your script.
A coroutine might work as well, but a spawn is easier to use (in my opinion).

Wiki links:
Coroutines: coroutine | Documentation - Roblox Creator Hub
Spawn: Documentation - Roblox Creator Hub

1 Like