GUI not always displaying right value

So I have a nametag gui which also displays a players level above their name however it seems to be a 50/50 if that value is actually the correct value as seen below:
image
The one on the left is working while the one on the right should display “Level: 3” but instead just stays at 1.

This is the script:
image

Ive tried doing the following:
image

But this makes the gui only appear above 1 player as seen below: (though it works for that 1 player)

image

Any help is appreciated

1 Like

local newtext = nametag:Clone()
Are you cloning the entire Surface Gui or just the text?

The entire surface gui (its called nametag)

Add a Print(player) to your code and see if the code is running for the two player or only one of them

image
shows both (printed name and level)

Do you change the value of the “Level” to test it out or is it 1?

Changed level from 2 to 3 and still stays at 2, also the other players randomly works every now and then like in the screenshot where it says 3 while most of the time it stays at 1

you are running this on .Changed, meaning the UI will only ever appear if a player levels up, this also means it will create a UI every time a player levels up. All of this code should be in CharacterAdded, the only thing that should be in .Changed is changing the UI’s Text via "Level: "..val Obviously you would also need this line outside the script as well

Im currently running this without the .Changed:
image
Is their a way to make this update correctly or is .Changed in the way you said the only way to do so?

.Changed is the correct way to check for a value change in a datatype instance

1 Like

You should update the label once when the character is added and then rely on .Changed to keep the label’s text updated.