Hello, I have had a recent problem and is that i can not save a BoolValue in a DataStoreService, i have seen several tutorials and nothing, i leave you the script that is in ServerScriptService.
--// VARS \\--
local DataStore = game:GetService("DataStoreService")
local plrData = DataStore:GetDataStore('PlayerSettingsSave')
--// FUNCTIONS \\--
local function onPlayerJoin(plr)
local folder = Instance.new('Configuration')
folder.Name = "PlayerSettingsData"
folder.Parent = plr
local Bool1 = Instance.new('BoolValue')
Bool1.Name = "LowGraphics"
Bool1.Parent = folder
local plrUserID = 'Player_'..plr.UserId
local data = plrData:GetAsync(plrUserID)
if data ~= nil then
Bool1.Value = plrData[1]
print("Data was found for "..plr.Name.." ("..plrUserID..")")
else
Bool1.Value = false
print("New player")
end
end
local function onPlayerLeft(plr)
local plrUserID = 'Player_'..plr.UserId
local success, err = pcall(function()
plrData:SetAsync(plrUserID, plr.PlayerSettingsData.LowGraphics.Value)
end)
if success then
print("Saved settings for "..plr.Name.." ("..plrUserID..")")
else
warn("Error while trying to save settings for "..plr.Name.." ("..plrUserID..")")
end
end
--// PLAYER FUNCTION \\--
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerLeft)
--// VARS \\--
local DataStore = game:GetService("DataStoreService")
local plrData = DataStore:GetDataStore('PlayerSettingsSave')
--// FUNCTIONS \\--
local function onPlayerJoin(plr)
local folder = Instance.new('Configuration')
folder.Name = "PlayerSettingsData"
folder.Parent = plr
local Bool1 = Instance.new('BoolValue')
Bool1.Name = "LowGraphics"
Bool1.Parent = folder
local data = plrData:GetAsync(plr.UserId)
if data ~= nil then
Bool1.Value = data
print(Bool1.Value)
print("Data was found for "..plr.Name.." ("..plr.UserId..")")
else
Bool1.Value = false
print("New player")
end
end
local function onPlayerLeft(plr)
local save = {}
table.insert(save, plr.PlayerSettingsData.LowGraphics.Value)
plrData:SetAsync(plr.UserId, save)
end
--// PLAYER FUNCTION \\--
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerLeft)
And it also got stuck on true so i dont know how to change it to false because it stays on true.