My coroutine is not working

I have a while loop in a coroutine and every time I resume the coroutine I get the error :

“08:05:31.601 Workspace.Lab1.bringWaterButton.bringWater:40: invalid argument #1 to ‘resume’ (thread expected, got table) - Server - bringWater:40”

Here is my Script :

local takeDamage = coroutine.create(function()
while true do
wait(.05)
local partsInRegion = game.Workspace:findPartsInRegion3(region,regionPart,100)

	for i,v in pairs(partsInRegion) do
		if v:FindFirstChild("Humanoid") then
			v.Humanoid.Health -= 1
		end
	end
end

end)

coroutine:resume(takeDamage)

I got this method off a very old video , I tried to find a new method but couldn’t , if there is one or I am simply doing this wrong , please tell me.

coroutine.resume, not coroutine:resume.

Oh thank you for the help. I thaught it was with the :

With the colon operator you’d be passing the coroutine library itself as the first argument to the called function, resume() in this case.

1 Like