Coins not showing with gui

So im using datastore2 and i tried putting in a local script inside a text label but it’s like the script isn’t there. It doesn’t make any changes or anything, how do i fix this?

local replicatedStorage = game:GetService("ReplicatedStorage")

replicatedStorage.RemoteEvents.UpdateClientCurrency.OnClientEvent:Connect(function(amount)
	script.Parent.Text = "$" .. amount
end)
1 Like

You’ll have to us the code that is trying to activate this RemoteEvent since there doesn’t seem to be any issue here besides that if amount is always going to be a number, you should make amount a string

script.Parent.Text = "$" .. tostring(amount)

doesn’t work it does the same thing, it doesn’t make updates

Then you’ll have to show the code that actually fires the Event

Hi, you should try printing if the event actually gets fired at all. If it doesn’t print anything there is something wrong with the script firing the event.

here

local function updateClientCurrency(amount)
			replicatedStorage.Events.UpdateClientCurrency:FireClient(player, amount)
		end
		
		updateClientCurrency(CurrencyStore:Get(DefaultCurrencyAmount))
		
		CurrencyStore:OnUpdate(updateClientCurrency)
		

oh, i added prints and nothing printed

Is the function even being called? Add a print inside it

Yeah, there could be something wrong with the function itself. It looks fine in my eyes tho.

i added a print in the function and nothing happened

There’s something wrong with the ‘CurrencyStore’ module probably. That’s the only clue I got right now.

Everything is saving correctly it’s just that the gui is not showing

local DataStore2 = require(ServerStorage:WaitForChild("DataStore2"))
local CurrencyStore = DataStore2("Currency", player)

Is the ‘:OnUpdate()’ function working correctly? Try printing there.

local function updateClientCurrency(amount)
			replicatedStorage.Events.UpdateClientCurrency:FireClient(player, amount)
			print("Cool")
		end
		
		updateClientCurrency(CurrencyStore:Get(DefaultCurrencyAmount))
		
		CurrencyStore:OnUpdate(updateClientCurrency)

Nothing happened

Show the code of the module to us.

heres the whole code

local replicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")

local DataStore2 = require(ServerStorage:WaitForChild("DataStore2"))

local DefaultCurrencyAmount = 1
game.Players.PlayerAdded:Connect(function(player)
	local InventoryStore = DataStore2("Inventory", player)
	local CurrencyStore = DataStore2("Currency", player)
	local replicatedDataFolder = Instance.new("Folder")
	replicatedDataFolder.Parent = replicatedStorage.ReplicatedData
	replicatedDataFolder.Name = player.UserId
	
	local inventoryString = Instance.new("StringValue")
	inventoryString.Parent = replicatedDataFolder
	inventoryString.Name = "Inventory"
	
	local inventoryData = InventoryStore:Get({})
	inventoryString.Value = HttpService:JSONEncode(inventoryData)
	
	InventoryStore:OnUpdate(function(decodedData)
		inventoryString.Value = HttpService:JSONEncode(decodedData)
		
		local function updateClientCurrency(amount)
			replicatedStorage.Events.UpdateClientCurrency:FireClient(player, amount)
			print("Cool")
		end
		
		updateClientCurrency(CurrencyStore:Get(DefaultCurrencyAmount))
		
		CurrencyStore:OnUpdate(updateClientCurrency)
		
		print("Again")
	end)
end)

game.Workspace:WaitForChild("Bruh").ClickDetector.MouseClick:Connect(function(player)
	
	local CurrencyStore = DataStore2("Currency", player)
	
	CurrencyStore:Increment(50,DefaultCurrencyAmount)
end)

It prints nothing of these? That’s very weird… I don’t see the solution though. Never used Datastores2 though.

local DataStore2 = require(ServerStorage:WaitForChild("DataStore2"))

DataStore2.Combine("DATA", "Inventory", "Currency")

I think you forgot to do this, it’s required you combine all your data fields like this for it to work

where do i add that?

After declaring the DataStore2 Variable, add the 2nd line afterwards