"Maximum event re-entrancy....." da heck is thisss!

My whole script was working fine, until today😔

I was first using this script in a “While loop”, the Level went crazy

Then used the “Changed” function, and now its showing this msg which I’ve never seen in my life!!

Any help or suggestion will be much appreciated🤍

Screenshot (478)

 --// XP Level
	
	local xp = status.XP
	local xp_level = plr_levels.XP
	local points = values.Points

	local levelGui = game_gui.Level
	local xpFill = levelGui.Bar.Cover.Fill
	local max = xp_level.Value * 5	
	
	xp.Changed:Connect(function()		
		if xp.Value >= max then
			xp.Value = 0
			xp_level.Value += 1
			points.Value += 1

			module.statusEntry(record_gui, "Leveled Up!", makeup.Colors.Cash)
			module.statusEntry(record_gui, "+1 Point", makeup.Colors.Cash)
		end

		levelGui.Num.Text = xp_level.Value
		
		local x = ((xp.Value * 100) / max) / 100
		xpFill:TweenSize(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .25)
	end)

Your entering an infinite loop with the connection.
Everytime xp is changed it’s firing your :Connect function but the function itself it also changing the value of xp making the function fire again (and again and again…)

2 Likes

I get it, but how do I fix it mannn…I’ve spent hours trying to figure out how to avoid the loop

Try this script, I made a variable that, when the same parameter is changed, changes and does not work again

--// XP Level

local xp = status.XP
local xp_level = plr_levels.XP
local points = values.Points

local levelGui = game_gui.Level
local xpFill = levelGui.Bar.Cover.Fill
local max = xp_level.Value * 5
local debounce = false

xp.Changed:Connect(function()
	if debounce then debounce=false; return end
	if xp.Value >= max then
		debounce=true
		xp.Value = 0
		xp_level.Value += 1
		points.Value += 1

		module.statusEntry(record_gui, "Leveled Up!", makeup.Colors.Cash)
		module.statusEntry(record_gui, "+1 Point", makeup.Colors.Cash)
	end

	levelGui.Num.Text = xp_level.Value

	local x = ((xp.Value * 100) / max) / 100
	xpFill:TweenSize(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .25)
end)
1 Like

Still the same error

One thing I’ve experimented is that, when I make two other values, and do the same thing with those, the error doesn’t happen

--/ 1 (Errorrrrr)
	
	local xp = values.Status.XP
	local xp_level = plr_levels.XP
	
	xp.Changed:Connect(function()
		if xp.Value >= 5 then		
			xp.Value = 0
			xp_level.Value += 1				
		end
	end)
	
	--/ 2 (Working perfectly)
	
	local wood = status.Wood
	local box = status.Box

	wood.Changed:Connect(function()
		if wood.Value >= 5 then		
			wood.Value = 0
			box.Value += 1
		end
	end)

Can you show the error and on which line