Hello, i’m ShyowwTheDev, you can call me Shyoww by short, and i will be showing you how to turn a TextLabel, into a stats value.
So first, you will need to add a ScreenGUI inside of StarterGUI, make sure your ScreenGUI properties have ResetOnSpawn off, then, inside of the ScreenGUI, add a TextLabel.
Second, you will add a LocalScript inside of the TextLabel (Leave the script alone for now).
Third, you will need to create a stats using leaderstats, if you don’t know how to, I recommend watching on YouTube or seeing tutorials on the DevForum itself. For example, i’ll be using a death stats:
game.Players.PlayerAdded:Connect(function(players)
local leaderboard = Instance.new("BoolValue", players)
leaderboard.Name = "leaderstats"
local Deaths = Instance.new("IntValue", leaderboard)
Deaths.Name = "Deaths" -- Make sure this is all together
Deaths.Value = 0
players.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
Deaths.Value = Deaths.Value + 1
end)
end)
end)
And, now, for the final step, you should now edit the LocalScript inside of the TextLabel, here’s the script:
local deaths = script.Parent.Parent.Parent.Parent.leaderstats:WaitForChild("Deaths") -- Name of the IntValue or BoolValue.
function changed()
script.Parent.Text = "deaths: " .. deaths.Value
end
deaths.Changed:Connect(changed)
And then, after all steps done, you should be good!
As you can see, the TextLabel gets the ammount of deaths i have from the leaderboard.
If you encounter any bugs, please tell me!
Peace!