Unable to Cast Value to Object

I haven’t exactly seen this error too often. You see, I’m trying to run a coroutine:

local RegenCoroutine = coroutine.wrap(function()
	SizeReached = true
	local Players = FindPlayersInMine()
	
		--teleport all players in the mine outside of the mine
		if #Players > 0 then
			for _,Player in ipairs(Players) do
				local TPs = workspace.MineCore.MineTPs:GetChildren()
				Player.Character:SetPrimaryPartCFrame(TPs[RandInt(1,#TPs)].CFrame*CFrame.new(0,3,0))
			end
		end
						
		workspace.MineCore.MineCover.CanCollide = true
						
		wait(10)
						
		RegenerateCave()
		workspace.MineCore.MineCover.CanCollide = false
end)
					
RegenCoroutine()

However, for some odd reason, after implementing some code completely unrelated to this, I get the error Unable to Cast value to Object.

Can I get bit of help here?

Can you post the stacktrace so we can at least see what script and line therein the error is occuring?

The error occurs at RegenCoroutine(), which is at the bottom of the script.

local Players = FindPlayersInMine()
Can we see that line?
It seems liike it’s from there the error

I’ve verified, it is not from FindPlayersInMine().

What line is it causing it?
It shoud tell you on Output

I just said, the error is caused on the RegenCoroutine() at the bottom of the script.

Yes, but it should tell you what’s causing it, it doesn’t seems it’s that,

Like what line inside function

It’s possible he can’t be more specific since hes running a coroutine. I think there’s a special way to pull errors out of those 1 sec

Uhm?
Coroutines will error normally like any function, as far as I know.

1 Like