Hello Everyone I’ve been making a UI controller which changes the theme of gradients using collection service.
In order to change it I have to change it in The StarterGui and also the PlayerGui.
The collection service tag isn’t there on the Gui in playerGui so I tried Getting the Descendants of the player gui and finding it by the table.
But the player:GetDescendants()
is returning an empty table for some reason.
Heres the script
local UIGradientController = {}
local player: Player = game.Players.LocalPlayer
local Cs = game:GetService("CollectionService")
function UIGradientController:ChangeTheme(c1,c2)
for _,v in ipairs(Cs:GetTagged("Gradient")) do
local playerDescendants = player.PlayerGui:GetDescendants()
--Change the existing one
local UI = playerDescendants[v]
print(playerDescendants) -- prints {}
if (UI ~= nil) then
UI.UIGradient.Color = ColorSequence.new(c1,c2)
end
local Gradient = v:WaitForChild("UIGradient")
Gradient.Color = ColorSequence.new(c1,c2)
end
end
function UIGradientController:Start()
UIGradientController:ChangeTheme(Color3.new(0,0,0), Color3.new(1,1,1))
end
return UIGradientController
I am using AeroGameFrameWork but it doesn’t matter in this case.
Any reason why its doing it. Also if any other method of doing this is also appreciated.