Script that shows how much money you have dont work

Sup scripters, what i am trying to do is when the money value changes, its gonna show the currency gui, then after 5 seconds it will disappear, very similar to gta v, but the problem is, i had the value on the text label itself, so i thought it would be a open handed value to exploiters saying (“hack the entire game here”), so i changed the value to “leaderstat” and i thought it would be more secure. Before changing it, it was working fine, no errors, not even me believed it was working, then i changed the value to the leaderstats anddddd, it stopped working, i put a print on it to test if it really worked and it printed!!!

however, this is the script

local player = game.Players.LocalPlayer

local money = script.Parent:WaitForChild("Text")
local moneyValue = player:WaitForChild("leaderstats"):WaitForChild("Money")

local countdown = 5
local lastUpdate = 0

moneyValue.Changed:Connect(function()
	money.Text = "$".. moneyValue.Value
end)

money:GetPropertyChangedSignal("Text"):Connect(function()
	print("text changed, now gui, please appear")
	
	lastUpdate = os.clock()
	
	money.TextTransparency = 0
	money.TextStrokeTransparency = 0.5
	
	wait(countdown)
	
	if os.clock() - lastUpdate > countdown then
		money.TextTransparency = 1
		money.TextStrokeTransparency = 1
	end
end)

just wanted to remind that the text changes, but the gui wont appear when it changes

Try printing this see if your condition can be meet/ true

print(os.clock() - lastUpdate, countdown)
	if os.clock() - lastUpdate > countdown then
		money.TextTransparency = 1
		money.TextStrokeTransparency = 1
	end

but its weird, even if it didnt meet the condition, this part is only for hiding the gui after the 5 seconds, the gui wont appear, nevermind it does

image

Have you pin pointed the problem I’m a little confused :thinking: if you have can you show me

Why not just do:

local player = game.Players.LocalPlayer

local money = script.Parent:WaitForChild("Text")
local moneyValue = player:WaitForChild("leaderstats"):WaitForChild("Money")

local countdown = 5
local lastUpdate = 0

money.Visible=false

moneyValue.Changed:Connect(function()
	money.Text = "$".. moneyValue.Value
	money.Visible=true
	wait(countdown)
	money.Visible=false
end)

because when the value changes like 1 second before the value changes again, it doesnt add more 5 seconds, and it worked before changing the moneyvalue location

yes, the text dont appear

yes, the text dont appear