Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My egg datastore isnt working, I tried everything, Why wont it work?

Asked by 4 years ago
Edited 4 years ago

Here is my datastore. It didnt save my data at all or print anything

local DataStoreService = game:GetService("DataStoreService")
local NewData = DataStoreService:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
    local data = Instance.new("Folder")
    data.Name = "data"
    data.Parent = player

    local eggs = Instance.new("IntValue")
    eggs.Name = "eggs"
    eggs.Parent = data

    local info
    local success, errormessage = pcall(function()
        data = NewData:GetAsync(player.UserId.."-eggs")
    end)

    if success then
        eggs.Value = info
    else
        print("There was an error whilst loading your data")
        warn(errormessage)
    end

end) 
game.Players.PlayerRemoving:Connect(function(player)
    local success, errormessage = pcall(function()
        NewData:SetAsync(player.UserId.."-eggs", player.data.eggs.Value)
    end)

    if success then
        print("eggs saved")
    else
        print("eggs not saved, error")
        warn(errormessage)
    end
end)
0
Is it printing anything? And on line 13, you can try and say local data instead of info. Then on line 19, you can say eggs.Value = data I think it is important to say data instead of info because inside the pcall you are saying data Soban06 410 — 4y

Answer this question