I watched a video on how to add currency, and now i want to add 2 currencies. I don't exactly know how.. I am very new to this if i could get some help that would be great
local currencyName = "Zimo"
local DataStore = game:GetService("DataStoreService"):GetDataStore("Currency")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local currency = Instance.new("IntValue")
currency.Name = currencyName
currency.Parent = folder
local ID = currencyName.."-"..player.UserId
local savedData = nil
pcall(function()
savedData = DataStore:GetAsync(ID)
end)
if savedData ~= nil then
currency.Value = savedData
print("Data Loaded")
else
--New player--
currency.Value = 750
print("New player to game")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ID = currencyName.."-"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end)
game:BindToClose(function()
-- When game is ready to shutdown
for i, player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("Server shuting down")
end
end
wait(5)
end)
Also if there is a better way to do this im open for it.

5 comments
Would I make a new script? cause if i put another IntValue it breaks the data save for the other currency
Used have to make another Datastore because the current Datastore you're using only saves one currency
Does it work for you? If so can you accept the answer?
Sadly no I tried adding another script but it doesnt load half of the time idk why I could be doing something wrong..
Did you put the Datastore in a serverscript?