Hello! I have wrote a boolean datastore and I am running into a problem.
Setting the value to "true" for the character Alice isn't happening, and it's being set to false. I noticed studio updated, and decided to make us have to commit scripts which is beyond annoying, and will probably end up changing back to normal in the foreseeable future, BUT, the problem still lies there for now as to why this doesn't function.
I made a server script to try to set the value to true when player added, and the DataStore overrides it, because of the "Playeradded" function, and the saving.
Here is my script, any and all help for this would be appreciated!!
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local BoolTestDataStore = DataStoreService:GetDataStore("emp44")
local data = {
--// Tools \\--
["Bloxxer"] = false,
["AngelicCrescent"] = false,
["RustedMaul"] = false,
["ConcreteMaul"] = false,
["DemonicCrescent"] = false,
["DragonFury"] = false,
["Equalizer"] = false,
["Slicer"] = false,
--// Chars \\--
["Alice"] = true,
}
Players.PlayerAdded:Connect(function(Player)
local BoolDataStore = nil
local bools = Instance.new("Folder")
bools.Name = "Bools"
bools.Parent = Player
for name, value in pairs(data) do
local new = Instance.new("BoolValue")
new.Name = name
new.Value = value
new.Parent = bools
end
local s, e = pcall(function()
BoolDataStore = BoolTestDataStore:GetAsync("uid-" .. Player.UserId)
end)
if s then
print("Getting Bool Data For: " .. Player.Name)
if BoolDataStore then
for name, value in pairs(BoolDataStore) do
Player.Bools[name].Value = value
end
print("Bool Data Loaded For: " .. Player.Name)
else
print("Created New Bool Data For: " .. Player.Name)
end
else
warn("Error Getting Bool Data For: " .. Player.Name)
end
end)
Players.PlayerRemoving:Connect(function(Player)
local BoolDataStore = {}
for name, value in pairs(Player.Bools:GetChildren()) do
BoolDataStore[value.Name] = value.Value
end
local success = pcall(BoolTestDataStore.SetAsync, BoolTestDataStore, "uid-" .. Player.UserId, BoolDataStore)
if success then
print("Successfully Saved Bool Data For: " .. Player.Name)
end
end)

1 comment
Can you save tables without using JSONEncode and JSONDecode???