Whenever A Certain Minigame starts the timer gets stuck at 0

Im trying to make a new minigame in my game cause I only have 2

The Issue is when the randomizer picks that certain minigame " the third one " the text gets stuck at 0 and nothing happens anymore

--LOCALS
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")
local Winner = Values:WaitForChild("Winner")
local Maps = ReplicatedStorage:WaitForChild("MapStorage"):GetChildren()
local Workspace = game:GetService("Workspace")
local Inround = Workspace:WaitForChild("Inround")

--MAIN
while true do
	local time = 15
	repeat wait(1)
		time = time - 1
		Status.Value = "Intermission.. "..time
	until time <= 0
	local RandomMap = Maps[math.random(1, #Maps)]:Clone()
	local Teleports = RandomMap:WaitForChild("Teleports"):GetChildren()
	local Randomtele = Teleports[math.random(2, #Teleports)]
	Status.Value = "Game Starting!"
	wait(2)
	Status.Value = "The Minigame is "..RandomMap.Name
	RandomMap.Parent = Workspace
	wait(2.5)
	for _, player in pairs(game.Players:GetChildren())do
		local Char = player.Character
		Char.Parent = Inround
		Char.Head.CFrame = Randomtele.CFrame
	end
	time = 60
	repeat wait(1)
		time = time - 1
		Status.Value = time.." Time Left.."
	until time <= 0 or Winner.Value ~= "" or #Inround:GetChildren() == 0
	if Winner.Value ~= "" then
		local plr = game.Players:WaitForChild(Winner.Value)
		Status.Value = plr.Name.." Has Won!"
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 50
		plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
		Winner.Value = ""
	else
		Status.Value = "Everyone Lost..."
	end
	wait(3)
	local InRound = Inround:GetChildren()
	for i = 1, #InRound do
		local plr = game.Players:GetPlayerFromCharacter(InRound[i])
		plr:LoadCharacter()
	end
	RandomMap:Destroy()
end 


Hi!

Are there any related errors displayed in the output?

1 Like
  19:12:03.643  Battle Heights auto-recovery file was created  -  Studio  -  C:/Users/mrtix/Documents/ROBLOX/AutoSaves
  19:12:26.577  Infinite yield possible on 'Complex Obby:WaitForChild("Teleports")'  -  Studio
  19:12:26.577  Stack Begin  -  Studio
  19:12:26.577  Script 'ServerScriptService.MinigameRunner', Line 18  -  Studio  -  MinigameRunner:18
  19:12:26.578  Stack End  -  Studio

Sorry I just relised when It said Infinite yeld and all of that stuff that ment the teleports wornt working I fixed it B)

Alright, I’m glad you got it working!

1 Like

Actually It happened again

I put teleporters and made a finish line and this happened again

  08:40:43.023  Infinite yield possible on 'Volcanic Cave:WaitForChild("Teleports")'  -  Studio
  08:40:43.023  Stack Begin  -  Studio
  08:40:43.023  Script 'ServerScriptService.MinigameRunner', Line 18  -  Studio  -  MinigameRunner:18
  08:40:43.023  Stack End  -  Studio

This time Im really confused and dont know how to do this please help

At this moment I don’t see any such mistakes in the script. Error is explaining that the script is in state of infinite yield while trying to find Teleports. I can’t know what exactly these Teleports are (probably a model containing hidden location parts in game), but are they managed by some other script? Could there be another script interrupting?

idk If any other scripts are breaking this one or not

Teleports are not in cloned map. Are any other script, lets say, inserting them before map is cloned? They are not present when server searches. At least not where it looks for them.

No theirs never no scripts always running in the backround

It doesn’t seem like the problem is regarding this script. Everything looks like it should work if ran, and also the error is showing there is no Teleports instance.

1 Like

whats a instance??? Im a little confused about that

“Instance” is an occurance of literally anything. It was just an expression for Teleport object.

Your script is in state of infinite yielding, in other words, being stuck on the same line of code. It is constantly waiting for Teleports to be added to your map (clone of course), because it can’t find any in the given map model.

Method :WaitForChild() takes two parameters: child name and timeout. If the former is not set, :WaitForChild yields infinitely. If timeout is set, waiting for descendant to be added ends after time is out. If that happens

local Teleports = RandomMap:WaitForChild('Teleports', 5)
-- Teleports is set to nil after 5 seconds if it isn't found in RandomMap, with 
-- second parameter there is no risk, but you don't need this, so maybe use 
-- other option:

local Teleports = RandomMap:FindFirstChild('Teleports') -- rather use this
-- Teleports is set to nil immediately if it's not found, risk of infinite yielding 
-- is eleminated

Now you only have to find out why there is no Teleports found.