Datastore not saving

I’m satisfied after this hour-long journey XD

It works thank you very much guys!

Um, can one of y’all show me how to remove the +1

Basically the same code, other than FindFirstChild as these are already defined.
Also, I’ve noticed Roblox is stating Atm: “We are aware that there is an issue with saving changes to avatars on Roblox. Our team is actively working on resolving this issue.”
Times like this it’s best not to get to into editing, especially with databases.

local dataStoreService = game:GetService("DataStoreService")
local players = game:GetService("Players")
local mainStore = dataStoreService:GetDataStore("MainDataStore")

players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder", player)
    local Subscribers = Instance.new("IntValue", leaderstats)
    Subscribers.Name = "Subscribers"

    pcall(function()
        Subscribers.Value = mainStore:GetAsync(player.UserId)
    end)
end)

players.PlayerRemoving:Connect(function(player)
    local leaderstats = player:FindFirstChild("leaderstats")
    local Subscribers = leaderstats:FindFirstChild("Subscribers")

    pcall(function()
        if Subscribers then
            mainStore:SetAsync(player.UserId, Subscribers.Value)
        end
    end)
end)