Current Level System for a Gui not Working

I am trying to make a current level system for upgrades in my shop. All of this should work but the text doesn’t change. How do I fix this?

Script:


local upgradesFolder = player:WaitForChild("Upgrades")

local upgrades = {
	
	multiplier = upgradesFolder:WaitForChild("Multiplier"),
	backpack = upgradesFolder:WaitForChild("Backpack"),
	cashPerSell = upgradesFolder:WaitForChild("CashGiver"),
	rankName = upgradesFolder:WaitForChild("name"),

}

function FindLevel()
	for i, d in pairs(script.Parent:GetDescendants("CurrentLevel")) do
		if d.Name == "CurrentLevel" then
			for i, upg in pairs(upgrades) do
				if d.Parent.Name == upg.Name then
					local label = d
					label.Text = string.gsub(label.Text, "_", upg.Value)--This text doesn't change for some reason whenever the value changes
				end
			end
		end
	end
end

FindLevel()

for i, upg in pairs(upgrades) do
	upg:GetPropertyChangedSignal("Value"):Connect(FindLevel)
end
1 Like

Are you getting any warnings or errors in your ouput?

Nope, no errors at all!!!

Here, the function GetDescendants() is in the object that you want to get its descendants. It doesn’t ask for any arguments.

Remember to use GetChildren() or the function that returns you a table with objects when you use pairs().

The first part doesn’t really change anything. The second part already is a table.

Have you tried with for i, d in pairs(script.Parent.CurrentLevel:GetDescendants() do?

I’m not sure what’s the object you’re trying to get its descendants.

The script’s parent is a Frame. The CurrentLevel TextLabels are all inside of different frames inside of the script’s parent.

Does it works when you use print()? LocalScripts inside UIs tend to stop working.

Yeah I tried printing the descendant and upg and they were all working correctly. It just wasn’t changing the text for some reason