How to save BoolValue in DataStore?

  1. What do you want to achieve? Keep it simple and clear!
    Saving Value of BoolValue in Data.
  2. What is the issue? Include screenshots / videos if possible!
    I tryed create BValue by Instance.new() in plr from datastore script, and save like that…
    But value not saving(
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    …like that:
game.Players.PlayerRemoving:Connect(function(plr)
	local success,err = pcall(function()
		myData:SetAsync(plr.UserId,plr.leaderstats.Coins.Value)
		myData:SetAsync(plr.UserId,plr.Gate1.Value) -- BOOLVALUE
	end)
	if err then
		warn(err)
	end
end)
1 Like

A small snippet of how to save bool values in datastores:

local DataStoreServ = game:GetService("DataStoreService")

local dataStoreLibrary = DataStoreServ:GetDataStore("testData")

game.Players.PlayerRemoving:Connect(function(plr)
local success, errorM = pcall(function()
dataStoreLibrary:SetAsync("boolValue", true)
end)
if success then
print("yay saved")
elseif errorM then
print("errorlol")
end
end)

I typed this out so it might be wrong.

Well you have the same key for two different saves so perhaps one is overriding the other?

yes, i know, i replace that, but when i save value i’ve get that issue

ServerScriptService.DataStoreScript:43: attempt to call missing method 'SetAsync' of table
code:

game.Players.PlayerRemoving:Connect(function(plr)
	print("VALUE IS ",plr.Gate1.Value)
	local success,err = pcall(function()
		myData:SetAsync(plr.UserId,plr.leaderstats.Coins.Value)
		GateData:SetAsync(plr.UserId,{plr.Gate1.Value})
	end)
	if err then
		warn(err)
	end
end)

Are you setting a table to a datastore? Check that those are actually bool values.

i just tryed to setting table, ye that are bool.
But how save it?

Print the booleans value and tell me what it is

local gate1 = Instance.new("BoolValue", plr)
gate1.Name = "Gate1"

I just create boolean for checking Gate open permission.

Send a screenshot of the console please.

You didn’t set the value of the bool.

1 Like

i set value in other script when buy permission for coins

But is the bool guaranteed to be set before saving?

no, i don’t know is the bool guaranteed.

but there is a pcall exception for this

What line is the error hinting to in the code? Which line is which?

GateData:SetAsync(plr.UserId,plr.Gate1.Value)

I gtg. I’ll get back to help in a little bit.

i think the data is initially in intValue, but I’m trying to assign to the Boolean database

Just to be sure, are you using a server script or local script?
And also what is the script’s parent?