So i have a script which makes a few (8) Bool Values inside of a folder which is in the player and its supposed to save those values when edited. And i have a script which determines the functions of a few Remote Events. For some reason when i edit one of the values using a different script only one changes but when i rejoin all of them become true, why is that?
Here is the Save script:
local DataStore = game:GetService("DataStoreService") local ds1 = DataStore:GetDataStore("NOPE") local ds2 = DataStore:GetDataStore("NOPEE") local success, err = pcall(function() game.Players.PlayerAdded:Connect(function(plr) wait(5) local Cars = Instance.new("Folder") Cars.Name = "OwnedCars" Cars.Parent = plr --------------------------------------------------------------------------------1 local DAFERRAOwned = Instance.new("BoolValue") DAFERRAOwned.Name = "DAFERRAOwned" DAFERRAOwned.Value = false DAFERRAOwned.Parent = Cars DAFERRAOwned.Value = ds2:GetAsync(plr.UserId, Cars.DAFERRAOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) DAFERRAOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.DAFERRAOwned.Value) end) --------------------------------------------------------------------------------2 local DAFERRARTOwned = Instance.new("BoolValue") DAFERRARTOwned.Name = "DAFERRARTOwned" DAFERRARTOwned.Value = false DAFERRARTOwned.Parent = Cars DAFERRARTOwned.Value = ds2:GetAsync(plr.UserId, Cars.DAFERRARTOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) DAFERRARTOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.DAFERRARTOwned.Value) end) --------------------------------------------------------------------------------3 local DAVENERAOwned = Instance.new("BoolValue") DAVENERAOwned.Name = "DAVENERAOwned" DAVENERAOwned.Value = false DAVENERAOwned.Parent = Cars DAVENERAOwned.Value = ds2:GetAsync(plr.UserId, Cars.DAVENERAOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) DAVENERAOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.DAVENERAOwned.Value) end) --------------------------------------------------------------------------------4 local HEKTORMEDIONAOwned = Instance.new("BoolValue") HEKTORMEDIONAOwned.Name = "HEKTORMEDIONAOwned" HEKTORMEDIONAOwned.Value = false HEKTORMEDIONAOwned.Parent = Cars HEKTORMEDIONAOwned.Value = ds2:GetAsync(plr.UserId, Cars.HEKTORMEDIONAOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) HEKTORMEDIONAOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.HEKTORMEDIONAOwned.Value) end) --------------------------------------------------------------------------------5 local MOUNTSRAKEOwned = Instance.new("BoolValue") MOUNTSRAKEOwned.Name = "MOUNTSRAKEOwned" MOUNTSRAKEOwned.Value = false MOUNTSRAKEOwned.Parent = Cars MOUNTSRAKEOwned.Value = ds2:GetAsync(plr.UserId, Cars.MOUNTSRAKEOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) MOUNTSRAKEOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.MOUNTSRAKEOwned.Value) end) --------------------------------------------------------------------------------6 local NOVENAACESERAOwned = Instance.new("BoolValue") NOVENAACESERAOwned.Name = "NOVENAACESERAOwned" NOVENAACESERAOwned.Value = false NOVENAACESERAOwned.Parent = Cars NOVENAACESERAOwned.Value = ds2:GetAsync(plr.UserId, Cars.NOVENAACESERAOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) NOVENAACESERAOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.NOVENAACESERAOwned.Value) end) --------------------------------------------------------------------------------7 local ROLANDGTROwned = Instance.new("BoolValue") ROLANDGTROwned.Name = "ROLANDGTROwned" ROLANDGTROwned.Value = false ROLANDGTROwned.Parent = Cars ROLANDGTROwned.Value = ds2:GetAsync(plr.UserId, Cars.ROLANDGTROwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) ROLANDGTROwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.ROLANDGTROwned.Value) end) --------------------------------------------------------------------------------8 local JELANSTERBETAOwned = Instance.new("BoolValue") JELANSTERBETAOwned.Name = "JELANSTERBETAOwned" JELANSTERBETAOwned.Value = false JELANSTERBETAOwned.Parent = Cars JELANSTERBETAOwned.Value = ds2:GetAsync(plr.UserId, Cars.JELANSTERBETAOwned.Value) --or false --game.Players.PlayerRemoving:Connect(function(plr) JELANSTERBETAOwned.Changed:connect(function() ds2:SetAsync(plr.UserId, Cars.JELANSTERBETAOwned.Value) end) end) ---------------------------------------------------------------------------------Cash game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder", player) leader.Name = "leaderstats" local Cash = Instance.new("IntValue", leader) Cash.Name = "Cash" Cash.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId.."-cash", Cash.Value) wait(5) --Cash.Changed:connect(function() print("SavingData") ds1:SetAsync(player.UserId.."-cash", Cash.Value) end) --end) game.Players.PlayerRemoving:connect(function(player) local SavedData = Instance.new("BindableEvent") ds1:setAsync(player.UserId, player.leaderstats.Cash.Value)--Cash ds2:setAsync(player.UserId, player.Cars.DAFERRAOwned.Value)--1 ds2:SetAsync(player.UserId, player.Cars.DAFERRARTOwned.Value)--2 ds2:SetAsync(player.UserId, player.Cars.DAVENERAOwned.Value)--3 ds2:SetAsync(player.UserId, player.Cars.HEKTORMEDIONAOwned.Value)--4 ds2:SetAsync(player.UserId, player.Cars.MOUNTSRAKEOwned.Value)--5 ds2:SetAsync(player.UserId, player.Cars.NOVENAACESERAOwned.Value)--6 ds2:SetAsync(player.UserId, player.Cars.ROLANDGTROwned.Value)--7 ds2:SetAsync(player.UserId, player.Cars.JELANSTERBETAOwned.Value)--8 print("SavingData") SavedData:Fire() game:BindToClose(function() SavedData.Event:Wait() end) end) end)
And here is the Remote Event script :
--------------------------------------------------------------------------1 game.ReplicatedStorage.DA_Ferra.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 200000 plr.OwnedCars.DAFERRAOwned.Value = true end) --------------------------------------------------------------------------2 game.ReplicatedStorage.DA_Venerra.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 400000 plr.OwnedCars.DAVENERAOwned.Value = true end) --------------------------------------------------------------------------3 game.ReplicatedStorage.DA_Ferra_F8_RT_Edition.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 500000 plr.OwnedCars.DAFERRARTOwned.Value = true end) --------------------------------------------------------------------------4 game.ReplicatedStorage.Hektor_Mediona.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 9000 plr.OwnedCars.HEKTORMEDIONAOwned.Value = true end) --------------------------------------------------------------------------5 game.ReplicatedStorage.Mounts_Rake.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 0 plr.OwnedCars.MOUNTSRAKEOwned.Value = true end) --------------------------------------------------------------------------6 game.ReplicatedStorage.Roland_Motors_GTR.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 25000 plr.OwnedCars.ROLANDGTROwned.Value = true end) --------------------------------------------------------------------------7 game.ReplicatedStorage.Voyage_Jalanster_Betamobili.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 20000 plr.OwnedCars.JELANSTERBETA.Value = true end) --------------------------------------------------------------------------8 game.ReplicatedStorage.Novena_Acesera.OnServerEvent:Connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 180000 plr.OwnedCars.DAACESERAOwned.Value = true end)
Please help i dont know what to do.