I want to be able to organize and quick access UI when a player joins my Roblox game. The issue is, I feel as though my solution is less effective than what would be considered as the most optimized way to do this.
Solution I have tried: Get the tagged objects fully loaded under PlayerGui after the character spawns, so that the CollectionService gets all the tagged UI within PlayerGui:
local CollectionService = game:GetService("CollectionService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() -- Don't need character, but hacky code to get playergui fully loaded
local UIButtons = CollectionService:GetTagged("UIButton")
After that, I looped through the returned table by UIButtons
and used this if statement to get rid of any tags associated with UI under the StarterGui:
for _, button in UIButtons do
if player:FindFirstChild(button.Name, true) then
tweenButton(button)
end
end
Any help would be greatly appreciated!