this script is not saving any thing in real game and studio i enabled the api access and not working any one can help me
Here Is The Script:-
local currencyName = "Cash" local expneededName = "ExpNeeded" local expName = "Exp" local levelName = "Level" local breathingName = "HaveBreathing" local birdName = "HaveBird" local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore") game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder") folder.Name = "stats" folder.Parent = player local currency = Instance.new("IntValue") currency.Name = currencyName currency.Parent = folder local expneeded = Instance.new("IntValue") expneeded.Name = expneededName expneeded.Parent = folder local exp = Instance.new("IntValue") exp.Name = expName exp.Parent = folder local level = Instance.new("IntValue") level.Name = levelName level.Parent = folder local havebird = Instance.new("IntValue") havebird.Name = birdName havebird.Parent = folder local havebreathing = Instance.new("IntValue") havebreathing.Name = breathingName havebreathing.Parent = folder local ID = currencyName.."-"..player.UserId local ID5 = expneededName.."-"..player.UserId local ID4 = expName.."-"..player.UserId local ID3 = levelName.."-"..player.UserId local ID2 = breathingName.."-"..player.UserId local ID1 = birdName.."-"..player.UserId local savedData = nil pcall(function() savedData = DataStore:GetAsync(ID) savedData = DataStore:GetAsync(ID5) savedData = DataStore:GetAsync(ID4) savedData = DataStore:GetAsync(ID3) savedData = DataStore:GetAsync(ID2) savedData = DataStore:GetAsync(ID1) end) if savedData ~= nil then currency.Value = savedData level.Value = savedData exp.Value = savedData expneeded.Value = savedData + 20 havebird.Value = savedData havebreathing.Value = savedData print("Data loaded") else -- New player currency.Value = 0 level.Value = 0 expneeded.Value = 20 exp.Value = 0 havebreathing.Value = 0 havebird.Value = 0 print("New player to the game") end exp.Changed:connect(function() if player.stats:WaitForChild("Exp").Value >= player.stats:WaitForChild("ExpNeeded").Value then level.Value = level.Value + 1 expneeded.Value = math.floor(expneeded.Value * 3) --You can change this if you want. exp.Value = 0 end end) game.ServerStorage.GiveExp.Event:Connect(function(amount,plr) if player.Name == plr.Name then exp.Value = exp.Value + amount end end) end) game.Players.PlayerRemoving:Connect(function(player) local ID = currencyName.."-"..player.UserId local ID5 = expneededName.."-"..player.UserId local ID4 = expName.."-"..player.UserId local ID3 = levelName.."-"..player.UserId local ID2 = breathingName.."-"..player.UserId local ID1 = birdName.."-"..player.UserId DataStore:SetAsync(ID1,player.stats[breathingName].Value) DataStore:SetAsync(ID2,player.stats[birdName].Value) DataStore:SetAsync(ID3,player.stats[expneededName].Value) DataStore:SetAsync(ID4,player.stats[expName].Value) DataStore:SetAsync(ID5,player.stats[levelName].Value) DataStore:SetAsync(ID,player.stats[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("This game is shutting down") end end wait(5) end)