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)