Im trying to save the players stat points and it works nice, but for some reason its not working for melee everytime, here is the script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("StatsDataStore") game.Players.PlayerAdded:Connect(function(player) local MeleeName = "MeleeP" local folder = player:WaitForChild("Data") local MeleeP = player:FindFirstChild("Data"):WaitForChild("MeleeP") local ID2 = MeleeName.."-"..player.UserId local savedData = nil pcall(function() savedData = DataStore:GetAsync(ID2) end) if savedData ~= nil then MeleeP.Value = savedData print("Data loaded") else -- New player MeleeP.Value = 1 print("New player to the game") end end) local MeleeName = "MeleeP" game.Players.PlayerRemoving:Connect(function(player) local ID2 = MeleeName.."-"..player.UserId DataStore:SetAsync(ID2,player.Data[MeleeName].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)
Thank you!