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

How To Save BoolValues?

Asked by 9 years ago

I am not sure how to save it, but i look up in wiki and this is what i made up i not even sure if you can even save BoolValues, but i think the only problem is how do i make contact with it like if the save is this then that. This is in a custom backpack inside workspace and in a model with boolvalues.

game.Players.PlayerAdded:connect(function(s)
    s:WaitForDataReady()
if script.Parent.Value == true then
    s:SaveBoolean("Found", true)
end
end)

game.Players.PlayerAdded:connect(function(r)
while wait() do
if script.Parent.Value == false then
    r:LoadBoolean("Found")
    break
    else break
end
end
end)

2 answers

Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

Since you didn't share whether your method worked or not, I'm going to assume it didn't and write a new script and explain it for you. Also, Data Persistence is outdated, and we use DataStores now (tutorial is in this answer).

local dataStore = game:GetService("DataStoreService"):GetDataStore("insertNameHere") --you can change the name of "insertNameHere"

game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
if script.Parent.Value then --just another way of seeing if something is true
dataStore:UpdateAsync(player.Name.." boolean", script.Parent.Value) --DataStores use UpdateAsync instead of Save(Value) to save things. this will create an async that saves this data for later use. use dataStore:GetAsync(key) to get the async. also, the "player.Name..boolean" is the key for the async.
end
end)

Think of DataStores like this. The DataStore is the file cabinet, the Async is a folder, and the papers in the folder are the users' data.

Ad
Log in to vote
-1
Answered by 9 years ago

Looks like you did it right here is a example of how to make a data persistent leaderboard using it.

In a Regular Script.

game.Players.PlayerAdded:connect(function(p)
    p:WaitForDataReady()
    if p:LoadInstance("leaderstats")~=nil then
        p:LoadInstance("leaderstats").Parent=p
    end
end)
game.Players. PlayerRemoving:connect(function(p)
    p:SaveInstance("leaderstats",p.leaderstats)
end)

as you can see looks like you did everything correct

0
please rep if you like the answer nstrike159 15 — 9y
0
i think i frogot to say that this is in a custom backpack inventory if you find it its becomes true that you found it and it saves and i don't need a leader board so sorry :( Anthony9960 210 — 9y

Answer this question