Thread is not yieldable error

So I made a function, except I keep getting the error thread is not yieldable where I use task.wait near the end of the function, why? And how do I fix it?

local function UpdatePlayers()
	print('Updated')
	
	TriggerKey += 1
	local Key = TriggerKey
	
	-- || Debounce ||
	if Debounce then
		print(Debounce)
		repeat task.wait(1) until not Debounce or TriggerKey ~= Key
		
		if TriggerKey ~= Key then return end
	end
	
	-- || Actual Stuff ||
	Debounce = true
	
	local DataUpdated:boolean = DeepCheck(CurrentData,LastSentData)
	print(CurrentData,LastSentData,DataUpdated)
	
	
	if DataUpdated then -- || Data isnt the same ||
		LastSentData = CurrentData
		print('Fired')
		MessageEvent:FireAllClients(CurrentData)
	end
	
	task.wait(1)
	
	Debounce = false
end

Figured it out, metatables cant contain any yields.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.