I was following an Alvinblox tutorial, but I made changes to the data store script to make it work with 2 currency's, I've manged to debug most of it, but for some reason it isn't working when I tested in the public test game.
I think it's this --->
if savedData ~= nil then currency.Value = savedData print("Data Loaded") else
part of the script that's not working correctly, since it's not printing "Data Loaded" I decided to post the whole script just in case it's not this part.
local currencyName = "Loot" local currencyName2 = "Gold"
--Data store has been created-- local DataStore = game:GetService("DataStoreService"):GetDataStore("LootandGoldTestingData")
print("Loot and Gold datastore created ^^ ")
--Currency folder has been created-- game.Players.PlayerAdded:Connect(function(player) ~~~~~~~~~~~~~~~~~
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local currency = Instance.new("IntValue")
local currency2 = Instance.new("IntValue")
currency.Name = currencyName
currency2.Name = currencyName2
currency.Parent = folder
currency2.Parent = folder
print("Loot and gold leaderboard/currency folder has been created ^^ ")
local ID = currencyName.."-"..player.UserId
local ID = currencyName2.."-"..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 = 0
currency2.Value = 100
print("New player has joined the game")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local ID = currencyName.."-"..player.UserId
local ID = currencyName2.."-"..player.UserId
DataStore:GetAsync(ID,player.leaderstats[currencyName].Value)
DataStore:GetAsync(ID,player.leaderstats[currencyName2].Value)
end)
game:BindToClose(function()
--When game is ready to shut down--
for i, player in pairs(game.Players:GetPlayers())do
if player then
player:Kick("This server is shutting down")
end
end
wait(5)
end)
(If this script is ACTUALLY correct it might be that I'm testing this wrong.)

2 comments
make all scripts code block
how?