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")


Players.PlayerAdded:Connect(function(Player)              
	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
end) -- To here. I just need help below, thanks! \/

Players.PlayerAdded:Connect(function(Player)
	local UserID2 = Player.UserId
	local Currency1 = WalletDatastore:GetAsync(UserID2)


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

	local FolderData = Player:WaitForChild("Data")

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

	Wallet.Value = Currency1

	Wallet.Changed:Connect(function(NewValue)
		WalletDatastore:SetAsync(UserID2, NewValue)
	end)
end)

Players.PlayerAdded:Connect(function(Player)
	local UserID1 = Player.UserId
	local Currency2 = BankDatastore:GetAsync(UserID1)

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

	wait()
	local DatFolder = Player:WaitForChild("Data")

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

	Bank.Value = Currency2

	Bank.Changed:Connect(function(NewValue)
		BankDatastore:SetAsync(UserID1, NewValue)
	end)

end)

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?

Yes.

I still need to know why did you put it GetAsync

Are you sure you are not getting errors?

Yup,

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

Ok,

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.

https://gyazo.com/42704a34846d9d3c5f04ed3c9a76ab4e

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:
2021-01-14
It should look like that:
2021-01-14 (1)

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