Maximum event re-entrancy depth (80) exceeded for ScriptContext.ErrorDetailed and .Error

I am making a round system for my game but it gives out this error and crashes my game. I tried to look up the forum but i couldn’t find anything except this information :

Can someone help me solve this? Heres the script ;

local rs = game:GetService("RunService")

local TimeGoneBy = 0
local IntermissionTime = 10
local GameplayTime = 10

local GameState = "Lobby"

local spawnpoint = workspace.spawner

local Players = game:GetService("Players")

local Folder = workspace.Blocks

local Inside = Folder:GetChildren()
local gameEnded = false

local colorpart = workspace.colorpart

local RandomColors = { 
	 Color3.fromRGB(255, 255, 0);
	 Color3.fromRGB(0, 0, 255);
	 Color3.fromRGB(255, 0, 0);
	 Color3.fromRGB(85, 255, 0);
	 Color3.fromRGB(255, 85, 0);
	 Color3.fromRGB(255, 255, 255);
	 Color3.fromRGB(0, 0, 0)
}

local rounds = 0


function onHeartBeat (Step)
	
	TimeGoneBy += Step
	
 
  if TimeGoneBy >= IntermissionTime and GameState == "Lobby" then
		TimeGoneBy = 0
		GameState = "GameStarted"
		for _,player in ipairs(game.Players:GetPlayers()) do
			local character = player.Character
			character.HumanoidRootPart.Position = spawnpoint.Position
		end
		print("Choosing the color")
	end
  
  while GameState == "GameStarted" do
		
		if TimeGoneBy >= 6  then
            TimeGoneBy = 0
			colorpart.Color = RandomColors[math.random(1, #RandomColors)]
			rounds = rounds + 1
		end
  end

	
end


--for _, Search in ipairs(Inside) do
--	if Search:IsA('BasePart') then
--		print("Works")
--		Search.Color =  RandomColors[math.random(1, #RandomColors)]
--	end
--end



rs.Heartbeat:Connect(onHeartBeat)

You’re creating a while true do loop every frame, so it’s going to crash almost immediately. Not sure what you wanted to achieve though, there’s a lot of missing details.

My game was crashing because of this script and i just wanted to know why, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.