Error called Maximum re-entrancy depth (80) While working with parallel luau

I’m getting a strange error while working with actors and parallel Luau.
image

Here is the code

for i = 1, 25 do
	local actor = game:GetService("ServerStorage").Actor:Clone()
	
	actor.Parent = script.Parent -- ServerScriptService
	
	actor:GetAttributeChangedSignal("ScriptLoaded"):Wait()
	
	actor:SendMessage("Hello")
	actor:GetAttributeChangedSignal("Finished"):Wait()
end
-- this script is parented to the actor
local actor = script:GetActor()

actor:BindToMessage("Hello", function()
	actor:SetAttribute("Finished", true)
end)

actor:SetAttribute("ScriptLoaded", true)

The error occurs when the for loop reaches number 20,

I noticed that the error coming from calling SetAttribute() The weird thing is that the script doesn’t break.
+
I also noticed that if I use task.wait() before calling SetAttribute(), it works fine.

Does anyone know what might be causing this error? What would be the best solution to fix it?

I would greatly appreciate any responses.

1 Like

“Re-entracy” is when the same function calls itself indirectly, over and over, leading to a freeze. For example:

Humanoid:GetPropertlyChangedSignal("Health"):Connect(function()
    Humanoid.Health -= 1
end)

I’m not sure why it’s happening here, though. Is there a stutter right before the error appears?

1 Like

No, it executes immediately. I did a quick search about this issue and found that no one else seems to be getting this specific error. Most other errors mentioned were related to maximum re-entrancy depth (80) for a specific event. This error doesn’t show which event is causing it.