How do I make a GUI that shows the stats in your leaderstats?
Asked by
7 years ago Edited 7 years ago
I'm currently making a GUI Frame that has two things: A TextLabel for Coins
, and a TextLabel for Diamonds
. I'm adding function to make it update whenever the Coins/Diamonds stat changes in player's leaderstats
.
This script and GUI is also not for making a leaderboard and replacing the ROBLOX's default one, but it could be a leaderboard that replaces ROBLOX's default one.
I scripted it, but the problem is, it's not working, and it doesn't show any wrong errors.
If you guys know what's happening that is wrong, or have any tips, tell me please!
01 | local player = game.Players.LocalPlayer |
02 | local statgui = player.PlayerGui:WaitForChild( "StatGUI" ) |
03 | local frame = statgui:WaitForChild( "Frame" ) |
04 | local coinframe = frame:WaitForChild( "CoinFrame" ) |
05 | local diamondframe = frame:WaitForChild( "DiamondFrame" ) |
07 | local coins = coinframe:WaitForChild( "Label" ) |
08 | local diamonds = diamondframe:WaitForChild( "Label" ) |
10 | function updateStatsToGUI() |
11 | local leaderstats = player:WaitForChild( "leaderstats" ) |
12 | local coinsval = leaderstats:WaitForChild( "Coins" ) |
13 | local diamondsval = leaderstats:WaitForChild( "Diamonds" ) |
14 | coins.Text = ( " " ..coinsval.Value.. " Coins" ) |
15 | diamonds.Text = ( " " ..diamondsval.Value.. " Diamonds" ) |
19 | coins.Changed:connect(updateStatsToGUI) |
20 | diamonds.Changed:connect(updateStatsToGUI) |