Quick help with coroutine

Quick question: Why does this only work for the first resume, I performed? I know I have to use coroutine.yield() but I don’t where I would use it. I’m sure it’s the while wait() loop that will restrict me from using yield()

local Interaction = coroutine.create(function(Frame, KeyText, ActionText, Action, Key, TaggedParts)
	while wait() do
		Frame.Visible = false
		for _,item in pairs(TaggedParts) do
			if (item.PrimaryPart.Position - humanoid.Position).magnitude <= 6 and mouse.Target == item.PrimaryPart then	
				Frame.Visible = true
				ActionText.Text = Action
				KeyText.Text = Key
				break
			end
		end
	end	
end)

coroutine.resume(Interaction, AboveHoverFrame, AboveKey, AboveAction, "Open", "E", Doors)

coroutine.resume(Interaction, BelowHoverFrame, BelowKey, BelowAction, "Dispose", "LMB", Disposables)

It perfectly shows the GUI, for the Doors. But the disposables isn’t working.

The second coroutine.resume isn’t working because the Interaction is already running, you need to stop the coroutine with coroutine.yield() if the function is done.

local Interaction = coroutine.create(function(Frame, KeyText, ActionText, Action, Key, TaggedParts)
	while wait() do
		Frame.Visible = false
		for _,item in pairs(TaggedParts) do
			if (item.PrimaryPart.Position - humanoid.Position).magnitude <= 6 and mouse.Target == item.PrimaryPart then	
				Frame.Visible = true
				ActionText.Text = Action
				KeyText.Text = Key
				break
			end
		end
          coroutine.yield() -- stops the coroutine
	end	
end)

coroutine.resume(Interaction, AboveHoverFrame, AboveKey, AboveAction, "Open", "E", Doors)

coroutine.resume(Interaction, BelowHoverFrame, BelowKey, BelowAction, "Dispose", "LMB", Disposables)

Thank you! Would you say the while wait() loop would still work with a RunService.Heartbeat? I’m thinking of changing it.