Hello! I am having an issue where when I have an amount of money, and rejoin, it does not show. In Roblox Studio it does not do this. How can I fix this? Here is also what my problem is in a video.
Here is my script for the Money GUI, and Gem GUI. The Coin GUI Does not do this because it is using a different script.
function Comma(amount)
while true do
amount, k = string.gsub(amount, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k == 0) then
break
end
end
return amount
end
Players.LocalPlayer.leaderstats.Gems:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Text = " "..Comma(Players.LocalPlayer.leaderstats.Gems.Value)
end)
local function Display()
script.Parent.Text = " "..Comma(Players.LocalPlayer.leaderstats.Gems.Value)
end
Display()
Players.LocalPlayer.leaderstats.Gems:GetPropertyChangedSignal("Value"):Connect(Display)
Also did you try pressing F9 and checking dev console to see if there was any errors?
Maybe the player’s leaderstats instance doesn’t exist the moment the script is ran, so maybe you could try adding :WaitForChild
local Players = game:GetService("Players")
local Client = Players.LocalPlayer
local Leaderstats = Client:WaitForChild("Leaderstats")
local Gems = Leaderstats:WaitForChil("Gems")
local function Display()
script.Parent.Text = " "..Comma(Gems.Value)
end
Display()
Gems:GetPropertyChangedSignal("Value"):Connect(Display)
13:48:21.726 Stack Begin - Studio
13:48:21.726 Script 'Players.Annexsohn.PlayerGui.Gem Leaderstat.TextLabel.LocalScript', Line 4 - Studio - LocalScript:4
13:48:21.726 Stack End - Studio
local pl_s1 = game:GetService("Players")
local function Player(tp_t1)
local a1 = Instance.new("Folder", tp_t1)
a1.Name = "Leaderstats"
end
pl_s1.PlayerAdded:Connect(Player)