Why coroutine.status() is wrong?

I’m making script, which allows run. But the problem is that coroutine.status(StaminaChanger) is always suspended, even if it actually running.

local StaminaChanger = coroutine.create(function()
	while true do
		local Delta = RunService.RenderStepped:Wait()
		if Running == true and CurrentStamina > 0 then
			CurrentStamina = math.max(CurrentStamina - (RunStaminaUsage * Delta), 0)
			if CurrentStamina <= 0 then
				Weak = true
				Running = false
				CurrentSpeedMultiplayer = CurrentSpeedMultiplayer - WeakRunSpeed + WeakWalkspeed
				Humanoid.WalkSpeed = BaseWalkSpeed * CurrentSpeedMultiplayer
			elseif CurrentStamina <= 200 and Weak == false then
				Weak = true
				CurrentSpeedMultiplayer = CurrentSpeedMultiplayer - NormalRunSpeed + WeakRunSpeed
				Humanoid.WalkSpeed = BaseWalkSpeed * CurrentSpeedMultiplayer
			end
			PlayerStaminaBarDisplay.Size = UDim2.new(CurrentStamina / MaxStamina, 0, 1, 0)
			PlayerStaminaBarQuantityText.Text = tostring(math.round(CurrentStamina * 1000 / MaxStamina) / 10) .. "%"
		elseif Running == false and CurrentStamina < MaxStamina then
			CurrentStamina = math.min(CurrentStamina + (StaminaRegen * Delta), 1000)
			if CurrentStamina > 200 and Weak == true then
				Weak = false
				CurrentSpeedMultiplayer = CurrentSpeedMultiplayer - WeakWalkspeed + NormalWalkspeed
				Humanoid.WalkSpeed = BaseWalkSpeed * CurrentSpeedMultiplayer
			end
			PlayerStaminaBarDisplay.Size = UDim2.new(CurrentStamina / MaxStamina, 0, 1, 0)
			PlayerStaminaBarQuantityText.Text = tostring(math.round(CurrentStamina * 1000 / MaxStamina) / 10) .. "%"
		elseif Running == false and CurrentStamina >= MaxStamina then
			coroutine.yield()
		end
	end
end)

local function ToggleRun(actionName, inputState, inputObject)
	if actionName == "Run" and inputState == Enum.UserInputState.Begin then
		Running = true
		print(coroutine.status(StaminaChanger) .. ", start run")
		if coroutine.status(StaminaChanger) == "suspended" then
			coroutine.resume(StaminaChanger)
		end
		Humanoid.WalkSpeed = BaseWalkSpeed * CurrentSpeedMultiplayer
	elseif actionName == "Run" and inputState == Enum.UserInputState.End then
		Running = false
		print(coroutine.status(StaminaChanger) .. ", stop run")
		if coroutine.status(StaminaChanger) == "suspended" then
			coroutine.resume(StaminaChanger)
		end
		Humanoid.WalkSpeed = BaseWalkSpeed * CurrentSpeedMultiplayer
	end
end

can someone explain me, why coroutine.status() don’t work like needed, and why when I trying resume this coroutine, Delta became nil?

Also, there’s 1 error:
Players.GamEditoPro.PlayerGui.ScreenGui.MouseDisplay.GlobalController:1016: attempt to perform arithmetic (mul) on number and nil
which linked to:
CurrentStamina = math.min(CurrentStamina + (StaminaRegen * Delta), 1000)
but when checking all variables - they are all numbers.

Calling coroutine.status(co) can only return “dead”, “normal” or “suspended” while being called from outside of the coroutine co. To my understanding of coroutines the only way of getting “running” is to call status() on the coroutine itself from within of itself by coroutine.status(coroutine.running()) simply because coroutines are not the same as threads, they do not run at the same time, they just utilize the time when other one yields.

An example would be two for loops printing something and then waiting where one of them is (or both are) in a coroutine. While one loop executes the wait() statement, the other one runs until it yields or finishes.

local co = coroutine.create(function()
			for i=1,10 do
				print("Coroutine ".. tostring(i) .. " " .. coroutine.status(coroutine.running()))
				wait()
			end
		end)
		
		coroutine.resume(co)
		
		for i=1,10 do -- this loop is outside of a coroutine
			print("Normal ".. tostring(i) .. " " .. coroutine.status(co))
			wait()
		end

As to why Delta becomes nil - I have no idea, couldn’t replicate the same result with my testing.
(Sorry it took so long to reply - it took me a week to become a forum member…)