I have already created a little GUI bar that should show the player how much money he/she has. However, this isn't working.

moneyKey = 100
game.Players.PlayerAdded:connect(function(player)
	if player:WaitForDataReady() then
		local MoneyBox = game.StarterGui.ScreenGui.MoneyBox
		local ls = Instance.new("IntValue", player)
		ls.Name = "leaderstats"
		ls.Parent = player
		
		local money = Instance.new("IntValue", ls)
		money.Name = "Score"
		money.Parent = ls
		money.Value = player:LoadNumber(moneyKey)
		MoneyBox.Text = money.Value
	end
end)

game.Players.PlayerRemoving:connect(function(player)
	if player:FindFirstChild("leaderstats") then
		player:SaveNumber(moneyKey, player.leaderstats.money.Value)
	end
end)

On line 13 I try to make MoneyBox.Text equal to money.Value (i.e, how much money the player has). However, it doesn't actually do this. What have I done wrong here?

2 comments

0

datapersistence is deprecated. Use DataStore instead

0

Not everyone had learned DataStores. They are quite simple to be honest, but if he hasn't learned it, then DataPersistence is a fine substitute.