How can I get this to update on join

Hello! How can I make this load on join? Because my Text thingy only updates when the value is changed, and if they have 0, it just shows Loading… because that’s what I have set for a normal text, but how can I get to update once you join, again cause as I said if you have 0 of that stat and you join its gonna say loading… because it updates if you have a value that it can update too.

This is the Script:

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local TIME = 1
local EASINGSTYLE = Enum.EasingStyle.Quart -- Tween easing style
local EASINGDIRECTION = Enum.EasingDirection.InOut -- Tween easing direction

local Leaderstats = Players.LocalPlayer:WaitForChild("leaderstats")
local MoneyInt = Leaderstats:WaitForChild("Gems")
local MoneyText = script.Parent

local TransitionAmount ="IntValue") -- We create a new IntValue which represents the value of the player's money before it got changed
-- The text of the TextLabel cannot be tweened due to being a string, so we use an IntValue instead.

TransitionAmount.Value = MoneyInt.Value

MoneyInt.Changed:Connect(function(amount) -- Wait for the player's money to change
	local tween = TweenService:Create(
		{Value = amount}
	) -- Create a tween that changes TransitionAmount's value to the new money value.

TransitionAmount.Changed:Connect(function(amount) -- This function will fire every time the value of TransitionAmount changes, so during the tween.
	local player = game.Players.LocalPlayer
	local Short = require(game.ReplicatedStorage.Short)
	MoneyText.Text = Short.en(amount)


Thanks! Any help is appreciated :grinning_face_with_smiling_eyes:

1 Like

Create a way to detect if user data has loaded(for example a DataLoaded bool value). It will be useful for stuff like this(you can set the UI text for the first time after its set to true) and to safeguard player data(for example you will know if their data fails to load so you can handle it when they leave).