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 = Instance.new("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(
TransitionAmount,
TweenInfo.new(TIME, EASINGSTYLE, EASINGDIRECTION),
{Value = amount}
) -- Create a tween that changes TransitionAmount's value to the new money value.
tween:Play()
end)
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)
end)
Thanks! Any help is appreciated