TextLabel wont update

Code is meant to update my TextLabel every 2 seconds but when testing it just reads 0 even though that isnt the value. Kinda stuck on this as it doesnt give an error. Also first time actually asking for help as i couldnt find a topic related

local value = game:GetService("Players").LocalPlayer.leaderstats.Cash.Value

while true do 
	wait(2)
	local yes, no = pcall(function()
		script.Parent.CashLabel.Text =  "Cash: "..value
	end)

	if not yes then
		script.Parent.CashLabel.Text =  "Cash: N/A"
		warn("cash display for "..game.Players.LocalPlayer.Name.." ("..game.Players.LocalPlayer.UserId..")failed to load, reason is "..no)
	end
	
end

Remove the Value at the end, you are creating a replication of the value, not the actual value itself
Then for each reference to the Cash leaderstat, add .Value at the end, like value.Value

Here you go, just as @neweve2323 said, you were saving the initial value of 0 and then set the text label to 0 every two seconds

local value = game:GetService("Players").LocalPlayer.leaderstats.Cash

while true do 
	wait(2)
	local yes, no = pcall(function()
		script.Parent.CashLabel.Text =  "Cash: "..value.Value
	end)

	if not yes then
		script.Parent.CashLabel.Text =  "Cash: N/A"
		warn("cash display for "..game.Players.LocalPlayer.Name.." ("..game.Players.LocalPlayer.UserId..")failed to load, reason is "..no)
	end
	
end

script.Parent.CashLabel.Text = "Cash: "… value

I have added a space from the two dots… try it

It does the same thing whether there is a space or not. Also there’s 3 dots in that, it should be 2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.