Why is my text not updating?

Hello! I’m making a Title system where if you have enough currency, it will update your title. However, the text is not updating. And there are no errors in the output.

Code (ServerScript → ServerScriptService):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TitlesFolder = ReplicatedStorage:FindFirstChild("Titles")

local PurchaseCurrency = "Gems" -- What currency do you need to unlock ranks

local Players = game:GetService("Players")

local Titles = {"Basic", "Beginner", "Novice", "Pro", "Elite", "Champion", "Master", "Grandmaster", "Legend", "Immortal", "Slayer", "Developer", "Owner", "Patner"}
local TitlesRequirements = {0, 1000, 10000, 100000, 2000000, 10000000,50000000,100000000,1000000000,2000000000,5000000000,50000000000.500000000000}

local Nametag = script.Nametag

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(character)
		repeat wait() until character.Head

		local PlayerTag = Nametag:Clone()
		PlayerTag.Parent = character.Head
		PlayerTag.PlayerName.Text = Player.DisplayName
		
		local Plr = Player:FindFirstChild(Player.Name)
		local Currency = Player:FindFirstChild("leaderstats"):FindFirstChild(PurchaseCurrency)
		
		while wait() do
			Currency.Changed:Connect(function()
				for i,v in pairs(TitlesRequirements) do
					if v <= Currency.Value then
						if character.Head:FindFirstChild("Nametag") then
							PlayerTag:FindFirstChild("Title").Text = Titles[i]
							break
						end
					end
				end
		end)
	end
		character.Humanoid.Died:Connect(function()
			task.wait(4)
			local ClonedTag = Nametag:Clone()
			PlayerTag.Parent = character.Head
			PlayerTag.PlayerName.Text = Player.DisplayName
			for i,v in pairs(TitlesRequirements) do
				if v <= Currency.Value then
					if character.Head:FindFirstChild("Nametag") then
						PlayerTag.Title.Text = Titles[i]
						break
					end
				end
			end
		end)
	end)
end)

Please help, Thanks!

In these situations, we live by the golden rule of debugging everything…

It is likely one of the many conditions you nested aren’t being respected, try to print out the result of these conditions to see if the behavior is as expected

Also, probably not intentional, so the last number in TitleRequirements has a . and not a ,

1 Like

Thanks! What would i print out tho, I?, v?

I’d put a print anywhere I’d want to check if it passes. So for example, I’d print v <= Currency.Value and so on. Although the script is unoptimized and does repeat the process, so you’d get a LOT of prints

1 Like

image
so like this?

I suppose that would work. If it does print out, you know for sure that it does reach the part where text is set, which narrows down the issue

1 Like

This is because your not updating the Display Name of the player, however you are with the name tag. You can simply make the Player’s display name the new nametag.

if character.Head:FindFirstChild("Nametag") then
	    PlayerTag:FindFirstChild("Title").Text = Titles[i]
        Player.DisplayName = PlayerTag:FindFirstChild("Title").Text 
	break
end

Tell me if this helps or not

1 Like

Thanks! But its the Title label thats not updating, not the PlayerName

Nothing gets printed sadly :frowning:

strong text

Now we know that one of the conditions to setting the text isn’t meant. Go print out the conditions before the if statements to see if they give an expected output

1 Like

Thanks! i cant do it rn as im busy. ill do it later tho