Attempt to yield across metamethod/C-call boundary Error

Hey y’all,

ive been having an issue where trying to sort a table always returns an error:
attempt to yield across metamethod/C-call boundary
and
cannot resume non-suspended coroutine

below is the sort function that throws the error

table.sort(Playeringame,function(a,b)
		return game.ReplicatedStorage.ServerEvents.FetchData:InvokeServer(a,'Points')  > game.ReplicatedStorage.ServerEvents.FetchData:InvokeServer(b,'Points')
	end)

am i doing this wrong? i have other functions that sort tables the exact same way, but dont throw errors.

I would fetch the data before sorting it, table.sort is a “c side” function and you can’t yield in it

1 Like