Hey, I'm having some trouble with a currency handler. Can someone help?

Hey, devfourm. I’m working on a game, I’ve decided to add a currency system to the game to allow users to continue buying builds ingame. I’ve made a simple currency handler but I can’t tell why the datastore is not working. I’m getting nothing in output but it’s not working. Tell me if you can help!

The Script

local Players = game:GetService("Players") -- Don't mind from here
local DataStoreService = game:GetService("DataStoreService")
local WalletDatastore = DataStoreService:GetDataStore("WalletDataStore")
local BankDatastore = DataStoreService:GetDataStore("BankDatastore")

	local DataFolder = Instance.new("Folder", Player)
	DataFolder.Name = "Data"
	if Player:GetRankInGroup(9039838) >= 254 then
		local ModValue = Instance.new("BoolValue", DataFolder)
		ModValue.Name = "Moderator"
		ModValue.Value = true                                
end) -- To here. I just need help below, thanks! \/

	local UserID2 = Player.UserId
	local Currency1 = WalletDatastore:GetAsync(UserID2)

	if Currency1 == nil then
		Currency1 = 0
		WalletDatastore:GetAsync(UserID2, Currency1)

	local FolderData = Player:WaitForChild("Data")

	local Wallet = Instance.new("IntValue", FolderData)
	Wallet.Name = "Wallet"

	Wallet.Value = Currency1

		WalletDatastore:SetAsync(UserID2, NewValue)

	local UserID1 = Player.UserId
	local Currency2 = BankDatastore:GetAsync(UserID1)

	if Currency2 == nil then
		Currency2 = 0
		BankDatastore:GetAsync(UserID1, Currency2)

	local DatFolder = Player:WaitForChild("Data")

	local Bank = Instance.new("IntValue", DatFolder)
	Bank.Name = "Bank"

	Bank.Value = Currency2

		BankDatastore:SetAsync(UserID1, NewValue)


I just noticed the wait, I’ve removed it and it still does not work.

You can’t put 2 arguments in GetAsync… I think you meant to put SetAsync

That is not my problem, the datastore won’t save no matter what.

Thanks for pointing that out though.

Yeah if it gave error it will break.

Also, why do you have 2 functions at playerAdding?

I made this in an old game, so I put the two scripts together to be more efficient.

Do you have API service Enabled?


I still need to know why did you put it GetAsync

Are you sure you are not getting errors?


You won’t get errors in the client, because the data stores should be in Server Script.


I tried your script on empty baseplate it worked for me.

Yeah, I forgot to ask you. How do you change the value ?

Lemme show you my side.


I changed the value manually. Like by going into data and changing it.

NOTE [The GUI in the bottom right does not have a script and is not active.]

On the client? if you are doing it on the client it won’t change on the server, so your data will stay stuck at 0. Switch to server side and change the value using this button:
It should look like that:
2021-01-14 (1)

dayumm, I’m an idiot. sorry for wastin ur time.