I’m getting a strange error while working with actors and parallel Luau.
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.