Leaderstat Nametag

I’m trying to create a nametag that displays a players stage.
Currently it just shows the stage as 0.

Here is the cloning code:

local nametag = game:GetService("ServerStorage"):WaitForChild("NameTagGui")

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		char:WaitForChild("Humanoid").HealthDisplayDistance = 0
		char:WaitForChild("Humanoid").NameDisplayDistance = 0
		
		local cloneTag = nametag:Clone()
		cloneTag.Frame.NameText.Text = plr.Name
		cloneTag.Parent = char.Head
	end)
end)

The cloning code works.

This is a view of the nametag inside explorer.
help

Code for local script:

while true do
	local CurStage = player.leaderstats.Stage.Value
	wait(0.1)
	script.Parent.Text = CurStage
end

The current code makes it only show local.

Could someone help? Thanks.

1 Like

There may be some issues with your notes being lines of code and not notes

-- This is a note!
This is code!

do this inside of a normal script:

while wait(0.1) do
    local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent) --change to character it is inside
    script.Parent.Text = player.leaderstats.Stage.Value
end
1 Like

Strange, doesn’t seem to show, the stage shows as 0 (Default text).

1 Like

are there any errors in the output?

1 Like

I see:
[Workspace.Inceptual.Head.NameTagGui.Frame.Stage.TextLabel.Script:3: attempt to index nil with ‘leaderstats’]

1 Like

oh alr, I thought that there were less parents needed, so do it like this instead:

local player

repeat
    player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent.Parent.Parent)
until player ~= nil

player.leaderstats.Stage:GetPropertyChangedSignal("Value"):Connect(function(value)
    script.Parent.Text = value
end)
3 Likes

Seems like it worked, Thanks for the help!

1 Like

No need to do while wait(0.1) do, IntValues have a Changed event that fires when the value is changed.

yes, and I wasnt thinking about it at that time. I’ll just update the script.