Text will not update on NumberValue change

Hello, I am making a language setting button, apparently, it does update the NumberValue, but for my street code, it does not work and update.

Code;

local plr = game.Players.LocalPlayer
local Language = plr:WaitForChild("PlayerGui"):WaitForChild("MenuGui"):WaitForChild("Settings"):WaitForChild("Language"):WaitForChild("LanguageBool")

local function run()
	if Language.Value == 0 then
		for i,v in pairs(script.Parent:GetDescendants()) do
			if (v.ClassName == tostring("TextLabel")) then
				v.Text = "Bike Lane"
			end
		end
	elseif Language.Value == 1 then
		for i,v in pairs(script.Parent:GetDescendants()) do
			if (v.ClassName == tostring("TextLabel")) then
				v.Text = "Piste Cyclable"
			end
		end
	end
end

run()
Language.Changed:Connect(run)local plr = game.Players.LocalPlayer
local Language = plr:WaitForChild("PlayerGui"):WaitForChild("MenuGui"):WaitForChild("Settings"):WaitForChild("Language"):WaitForChild("LanguageBool")

local function run()
	if Language.Value == 0 then
		for i,v in pairs(script.Parent:GetDescendants()) do
			if (v.ClassName == tostring("TextLabel")) then
				v.Text = "Bike Lane"
			end
		end
	elseif Language.Value == 1 then
		for i,v in pairs(script.Parent:GetDescendants()) do
			if (v.ClassName == tostring("TextLabel")) then
				v.Text = "Piste Cyclable"
			end
		end
	end
end

run()
Language.Changed:Connect(run)

Explorer;
image

I have tried re writing the code, and much more debugs.

Final note;
I put debug statements, like print("LINE TEST ONE"), and it did not print.

Any ideas?

BoolValues will only be true or false. You’re checking if it’s 0 or 1.

Ah, reading this reply made me realize I had a typo. in the topic title…

the post title was numbervalues instead of bool values.

(EDIT: fixed the typo)

Try this. The only reason why it wouldn’t run is if the pathing for the “Language” variable is wrong. But even then you should see a warning in output that says something like “Infinite yield possible”.

Edit: I don’t think this would cause an issue but your use of “tostring” isn’t doing anything. It’s already a string if it’s in the quotations.

v.ClassName == “TextLabel”

local plr = game.Players.LocalPlayer
local Language = plr:WaitForChild("PlayerGui"):WaitForChild("MenuGui"):WaitForChild("Settings"):WaitForChild("Language"):WaitForChild("LanguageBool")

local function run(Value)
print(Value)
end

run()
Language.Changed:Connect(run)

It doesn’t print any infinite yields…

(p.s: I am aware that tostring doesn’t do anything in this case.)

Is this local script parented inside workspace?? because local script won’t work inside workspace

1 Like

Yeah, it is. I will try re writing this into the StarterPlayerScripts…

EDIT: It now works, thanks!