**How to Make this script to save 2 bool values and create? **
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("BoolSave") game.Players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder",player) folder.Name = "stats" local bool = Instance.new("BoolValue",folder) bool.Name = "BoolValue" bool.Value = ds:GetAsync(player.UserId) or false ds:SetAsync(player.UserId, bool.Value) end) game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.stats.BoolValue.Value) end)
Instead of using game.Players.PlayerRemoving
you should use bool.Change
if i have understood you correctly you want to save 2 values like this:
local ds1 = game:GetService("DataStoreService"):GetDataStore("BoolSave") local ds2 = game:GetService("DataStoreService"):GetDataStore("BoolSave") game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder", player) stats.Name = "Stats" local bool1 = Instance.new("BoolValue", player) bool1.Name = "BoolValue1" bool1.Value = ds1:GetAsync(player.UserId) or false local bool2 = Instance.new("BoolValue", player) bool2.Name = "BoolValue2" bool2.Value = ds2:GetAsync(player.UserId) or false bool1.Changed:Connect(function() bool1:SetAsync(player.UserId, bool1.Value) end) bool2.Changed:Connect(function() bool2:SetAsync(player.UserId, bool2.Value) end) end)