Waiting in a task.spawn

i found a solution to this problem

i just used coroutine.resume with a thread created using coroutine.create
this is the final code

local UI = require(game:GetService("ReplicatedStorage").UI)
		local PlayerData = GameDataManager:GetPlayerData(player)
		local PetrifiedEvent = game:GetService("ReplicatedStorage").Events.Petrified
		local Unpetrify = game:GetService("ReplicatedStorage").Events.Unpetrify
		
		for _, abilities in pairs(PlayerData.CurrentAbilities) do
			PetrifiedEvent:FireClient(player, abilities)
			UI:LockAbility(player, abilities.Name)
			task.wait(0.01)
		end
		
		local thread = coroutine.create(function ()
			task.wait(duration)
			for _, abilities in pairs(PlayerData.CurrentAbilities) do
				Unpetrify:FireClient(player, abilities, PlayerData.Character)
				UI:UnlockAbility(player, abilities.Name)
				task.wait(0.01)
			end
		end)
		
		coroutine.resume(thread)

Isn’t that just what i had told you to do ? If so, please mark mine as the solution.

i’m an idiot
can you tell me the reply i have to mark as solution

have you tried task.delay? it does the same thing as task.wait but without yielding and runs a function when the time is up

Don’t worry, you’re not!
Here is the reply:

i already fixed the issue, don’t worry
thanks anyways tho