Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How To Save BoolValues?

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

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.

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

2 comments

0

please rep if you like the answer

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 :(

This discussion is preserved as it was. New answers, comments, and votes are closed.