WaitForAttribute?

Is there a way I can make a thing similar to waitforchild but with attributes?

You can probably use a repeat loop. I recommend making a function so you can call it whenever you want without re-writing the whole code. I also added a warn in case it yields for too long.

local function WaitForAttribute(Object, AttributeName, MaxTime)
   MaxTime = MaxTime or 10;
   local Clock = os.clock();
   repeat
      if os.clock() - Clock >= MaxTime then
         warn("Possible infinite yield for "..AttributeName.." on "..Object.Name..".");
         break;
      end;
      game:GetService("RunService").Heartbeat:Wait(); -- You can switch to RenderStepped if you prefer but it shouldn't change that much
   until Object:GetAttribute(AttributeName) ~= nil;
   return Object:GetAttribute(AttributeName);
end;

local Test = WaitForAttribute(Character, "TestAttribute"); -- will yield until "TestAttribute" on Character won't be nil
8 Likes

If you only need to wait for the attribute to change then you can use the GetAttributeChanged signal

local Attribute = Instance:GetAttributeChangedSignal("Attribute game")
2 Likes