Hello, my problem is that my datastore saving system dosent work. I have tried many diffrent types of datastorages. The script is below:
–//Services
local Players = game:GetService(“Players”)
local DataStoreService = game:GetService(“DataStoreService”)–//Variables
local PlayerDataStore = DataStoreService:GetDataStore(“PlayerData”)–//Functions
local function OnPlayerRemoving(player)
local leaderstats = player.leaderstatslocal success, errorMessage = pcall(PlayerDataStore.SetAsync, PlayerDataStore, player.UserId, {
No = leaderstats.No.Value,
Level = leaderstats.Level.Value
})if not success then
warn(errorMessage)
end
endPlayers.PlayerAdded:Connect(function(player)
local playerData = PlayerDataStore:GetAsync(player.UserId) or {
No = 100,
Level = 1
}local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = playerlocal No = Instance.new(“IntValue”)
No.Name = “No”
No.Value = playerData.No
No.Parent = leaderstatslocal Level = Instance.new(“IntValue”)
Level.Name = “Level”
Level.Value = playerData.Level
Level.Parent = leaderstats
end)Players.PlayerRemoving:Connect(OnPlayerRemoving)
game:BindToClose(function()
for i, player in ipairs(Players:GetPlayers()) do
task.spawn(OnPlayerRemoving, player)
end
end)
(APIService is on btw)