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

I need to make a data store thing for my game, why isn't this working?

Asked by
Mpire_z -2
5 years ago

So i'm making a Christmas game, so it will be out by Christmas. This won't save for some reason, I am changing the values, and everything. Please help.

startCookies = 0
startMilk = 0
DataStore = game:GetService("DataStoreService")
DsC = DataStore:GetDataStore("CookiesDataStore")
DsM = DataStore:GetDataStore("MilkDataStore")
game.Players.PlayerAdded:Connect(function(plr)
    local Folder = Instance.new("Folder")
    local CookiesValue = Instance.new("NumberValue")
    local MilkValue = Instance.new("NumberValue")
    MilkValue.Name = "Milk"
    CookiesValue.Name = "Cookies"
    Folder.Name = "Currency"
    Folder.Parent = plr
    CookiesValue.Parent = Folder
    MilkValue.Parent = Folder
    CookiesValue.Value = DsC:GetAsync(plr.UserId) or startCookies
    MilkValue.Value = DsM:GetAsync(plr.UserId) or startMilk
    CookiesValue.Changed:connect(function()
    DsC:SetAsync(plr.UserId, CookiesValue.Value)
    print(plr.UserId.."'s Value of"..CookiesValue.Value)
    end)
    MilkValue.Changed:connect(function()
    print(plr.UserId.."'s Value of"..MilkValue.Value)
    DsM:SetAsync(plr.Userid, MilkValue.Value)
    end)
end)

Answer this question