I made a coroutine function to multitask the execution of this script, but the coroutine returns {} instead of data and it’s getting data correctly from the module, the data returned to client by remotefunction is also {}.
Remotes.Player.Ability.OnServerInvoke = function(player, abilityEnum)
local finalData = {}
if not debounce[player] then
coroutine.resume(coroutine.create(function()
debounce[player] = true
local data = AbilityModule[abilityEnum](player)
finalData = data
task.wait(data.cooldown)
debounce[player] = false
end))
end
return finalData
end
Same error even with task.spawn, i still get a empty table, + if i try print() function inside of task.spawn or coroutine it doesnt print anything in output.
i tried this, still nothing inside task.spawn doesn’t print
local finalData = {}
if debounce[player] == nil then
debounce[player] = false
end
print(debounce[player])--prints false
if not debounce[player] then
print(debounce[player]) --it prints false here
task.spawn(function()
debounce[player] = true
local data = AbilityModule[abilityEnum](player)
print("Executing")--doesn't print
finalData = data
print(finalData)
task.wait(data.cooldown)
debounce[player] = false
end)
end
return finalData