-
What do you want to achieve? Keep it simple and clear!
I would like to save a Boolean value to the datastore -
What is the issue? Include screenshots / videos if possible!
The Boolean value dos not save whilst the other values DO save -
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I have looked at 1 other post with instructions to fix, it said to
tostring()
one of the code blocks, the code block mentioned was not clarified
This is the datastore script with the leader stats management stuff
local ds = game:GetService("DataStoreService"):GetGlobalDataStore()
game.Players.PlayerAdded:Connect(function(plr)
--create a leaderstats folder for the player
local userMapInfo = Instance.new("Folder")
userMapInfo.Name = "userMapInfo"
userMapInfo.Parent = plr
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
--add a new leaderstat named wins
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Value = 0
wins.Parent = leaderstats
local map1Comp = Instance.new("BoolValue")
map1Comp.Name = "Map1 Completion"
map1Comp.Value = false
map1Comp.Parent = userMapInfo
wait()
local plrkey = "id_"..plr.UserId
local save1 = plr.leaderstats.Wins
local save2 = plr.userMapInfo["Map1 Completion"]
local Saved = ds:GetAsync(plrkey)
if Saved then
save1.Value = Saved[1]
save2.Value = Saved[2]
else
local NumberForSaving = {save1.Value, save2.Value}
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync("id_"..plr.UserId, {plr.leaderstats.Wins.Value, plr.userMapInfo["Map1 Completion"].Value})
end)
The leaderstat scripts is the EXACT same in the second place.
Here is a screenshot of the player’s leaderstats and other values to make visualizing easier: