Gui Issue Updating

I have text labels Text itself not working correctly, I have a Value that set to true, and Text is “SELECT” but when false it “LOCKED” but it doesn’t do that, it makes it “SELECT”

function resetButtonColors(magicName, magic)
	for _, Button in pairs(ScrollFrame:GetDescendants()) do
		if Button:IsA("ImageLabel") then
			Button.ImageColor3 = magic and Color3.fromRGB(85, 255, 127) or Color3.fromRGB(255, 0, 0)
		elseif Button:IsA("TextLabel") and Button.Name ~= "Element" then
			Button.Text = magic and "SELECT" or "LOCKED"
		end
	end
end

I just need to know what I did wrong and why it not working correctly.

Right below this just add print(magic) and tell what it prints. Also show the function that is firing “resetButtonColors” with the sent parameters.

I have the magic in

function resetButtonColors(magicName, magic)

as a primary magic bool value else where in my code

I’m asking what you’re sending. If magic is an actual BaseValue instance (e.g a BoolValue) then this will always be true:

Button.Text = magic and "SELECT" or "LOCKED"

As magic is never nil or false. Are you sure you weren’t trying to do:

Button.Text = magic.Value and "SELECT" or "LOCKED"

What I was trying to do was like when I have selected the magic, It Set to “SELECTED” and if I chose a other magic it reset what I had picked before to “SELECT” but I have other magics I haven’t unlocked that are set to “SELECT” when they aren’t supposed to and

Button.Text = magic and "SELECT" or "LOCKED"

The magic means PrimaryMagic.Value which is True or False

Found the solution.

function resetButtonColors(magicName, magic)
	for _, Button in pairs(ScrollFrame:GetDescendants()) do
		if Button:IsA("ImageLabel") then
			if Button.ImageColor3 ~= Color3.fromRGB(255, 0, 0) then
				Button.ImageColor3 = magic.Value == true and Color3.fromRGB(85, 255, 127) or Color3.fromRGB(255, 255, 0)
			end
		elseif Button:IsA("TextLabel") and Button.Name ~= "Element" then
			if Button.Text ~= "LOCKED" then
				Button.Text = magic.Value == true and "SELECT" or "SELECTED"
			end
		end
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.