Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Saving other values than leaderstats?

Asked by 3 months ago
Edited 3 months ago

Should I be able to save values other than leaderstats? I have a boolean directly inside the player in Players. I also have leaderstats. My leaderstats save correctly, however my boolean doesn't save. I am using the same method on both, and it never gives off any errors. (I am using GetAsync and SetAsync)

local datastore = game:GetService("DataStoreService")
local ds = datastore:GetDataStore("item")

game.Players.PlayerAdded:Connect(function(plr)

    local item = Instance.new("BoolValue",plr)
    item.Name = "Sparkles"

    local d1

    local y1 = pcall(function()
        d1 = ds:GetAsync(plr.UserId.."Sparkles-")
    end)

    if  y1 then
        item.Value = d1
    end


    local y1 = pcall(function()
        ds:SetAsync(plr.UserId.."Sparkles-",plr.Sparkles.Value)
    end)
end)
0
You don't have to use leaderstats to save. You can use any folder for your values KochbananemitGuave 167 — 3mo
0
Please post your code so we can fix it [ https://scriptinghelpers.org/help/how-post-good-questions-answers ] Leamir 2779 — 3mo
0
Okay, I uploaded the code :) XDgirl909090 143 — 3mo

1 answer

Log in to vote
1
Answered by 3 months ago

Yeah, you can definitely save a bool value in a player. You can add it as another parameter in SetAsync.

Example:

DataStore:SetAsync(player.UserId, true)
0
Can also save tables/dictionaries Leamir 2779 — 3mo
Ad

Answer this question