How Would I save Booleans in DataStore2

I have an issue with boolean values not being set to true or saving. I have tried many other methods but this is the first method I have tried that doesn’t work. It would be great if someone could help or explain to me how to set booleans and save them with DataStore2.

here is the current code im using

beginEvent.OnServerEvent:Connect(function(plr)
		userData.Stat.Add = tonumber(userData.Stat.Add) + 1
		local button = DataStore2("Buttons", plr):Get() 
		button["1Beginning"] = true
		DataStore2("Buttons", plr):Set(button)
		print("Updated")
	end)

You should try to save the “true” as numbers, for example 0 is false and 1 is true

Not sure whats happening in the code but if you want to set a value using Datastore2 then change your code to this:

beginEvent.OnServerEvent:Connect(function(plr)
		userData.Stat.Add = tonumber(userData.Stat.Add) + 1
		local button = DataStore2("Buttons", plr):Get() 
		button["1Beginning"] = true
		DataStore2("Buttons", plr):Set(button["1Beginning"])
		print("Updated")
	end)

I would just save them as 1 and 0. 1 being true, and 0 being false. Just like in others languages like C++. If you want to retrieve a value, do this way:

local dataYouWantToRetrieve = (data == 1)

And set data like this:

data = (dataYouWantToSet) and 1 or 0