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

My datastore script wont save anything, how do I fix this?

Asked by 4 years ago

here is the script

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("FruitSaveSystem")
local ds2 = datastore:GetDataStore("CoinSaveSystem")
local ds3 = datastore:GetDataStore("TalkToBeastSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
    local folder = Instance.new("Folder", plr)
    folder.Name = "leaderstats"
    local fruits = Instance.new("IntValue", folder)
    fruits.Name = "Fruits"
    local coins = Instance.new("IntValue", folder)
    coins.Name = "Coins"
    local talkedtobeast = Instance.new("BoolValue", folder)
    talkedtobeast.Name = "TalkedToBeast"

    fruits.Value = ds1:GetAsync(plr.UserId) or 0
    ds1:SetAsync(plr.UserId, fruits.Value)

    coins.Value = ds2:GetAsync(plr.UserId) or 0
    ds2:SetAsync(plr.UserId, coins.Value)

    talkedtobeast.Value = ds3:GetAsync(plr.UserId) or false
    ds3:SetAsync(plr.UserId, talkedtobeast.Value)

    fruits.Changed:connect(function()
        ds1:SetAsync(plr.UserId, fruits.Value)
    end)

    coins.Changed:connect(function()
        ds2:SetAsync(plr.UserId, coins.Value)
    end)

    talkedtobeast.Changed:connect(function()
        ds3:SetAsync(plr.UserId, talkedtobeast.Value)
    end)
end)

I have tried all kinds of things, its worked once. I cant get it to do it again, please help.

1 answer

Log in to vote
0
Answered by 4 years ago

dont use or, as far as i know it got a 50% change of setting 0 instead instead do this 1.create the stats 2. set the stats to 0 3. if the player has datasaves then set the stats to that value 4. if they dont have datasaves then set the save to their stat value

Ad

Answer this question