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!
local player = game.Players.LocalPlayer
local statgui = player.PlayerGui:WaitForChild("StatGUI")
local frame = statgui:WaitForChild("Frame")
local coinframe = frame:WaitForChild("CoinFrame")
local diamondframe = frame:WaitForChild("DiamondFrame")
local coins = coinframe:WaitForChild("Label")
local diamonds = diamondframe:WaitForChild("Label")
function updateStatsToGUI()
local leaderstats = player:WaitForChild("leaderstats")
local coinsval = leaderstats:WaitForChild("Coins")
local diamondsval = leaderstats:WaitForChild("Diamonds")
coins.Text = (" " ..coinsval.Value.. " Coins")
diamonds.Text = (" " ..diamondsval.Value.. " Diamonds")
end
coins.Changed:connect(updateStatsToGUI)
diamonds.Changed:connect(updateStatsToGUI)

2 comments
it doesn't work in Studio, but it works in Client. Which is still a good thing! Thank you!
Is this in a server script or a local script?