How to make a function trigger infinitely

Hello, recently i wanted to make an item spawning system. I don’t know how to make a certain function run every let’s say 15 seconds so that everyone can get the item

tl;dr I wan’t to know how to trigger a function every 15 seconds infinitely

while true do
      function()
      task.wait(15)
end
1 Like

what does task.wait mean or do?

It’s just wait() but better. I reccomend you look into the task library.

1 Like
while task.wait(15) do
	function()
end

Can also be rewritten with 1 less line of code. This is in fact more favorable to use since it waits 15 seconds from Roblox initially starting before executing the script for the first time as opposed to executing the script as soon as you enter the game while you are still loading.