Hi everyone,
I’m running into a problem with CollectionService and tagged GUI elements in a local player’s PlayerGui. Here’s the situation:
- I have some GUI elements in
StarterGuithat are tagged usingCollectionService. - These GUI elements (and the tags) replicate correctly to the player’s
PlayerGui. - I want to manipulate the GUI in
PlayerGuionly (e.g., highlight buttons, change visibility that have that certain tag).
The issue is that when I call CollectionService:GetTagged("TagName") on the client through my ModuleScripts which are immediately required with a ModuleLoader, it returns the original instances in StarterGui and not a single copy in PlayerGui, even though the tags themselves also exist on the PlayerGui copies.
I already wait for the game to be loaded in the ModuleLoader and wait for the PlayerGui too.
So my question is:
- Is there a way to reliably get only the PlayerGui instances of tagged objects with CollectionService?
- Or is there a recommended pattern to work with GUI tags that exist in PlayerGui without accidentally referencing StarterGui?
Any guidance or best practices for this situation would be much appreciated!
Thanks in advance!
EDIT
I discovered that adding a simple task.wait(5) in my ModuleLoader makes it work, the PlayerGui elements are fully available by then, and CollectionService:GetTagged returns PlayerGui instances.
However, this feels like a hack. Is there a proper or reliable way to wait until PlayerGui is fully replicated before loading modules that depend on it?