Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If one bool value is true then all others are made true too when saving data, why?

Asked by 3 years ago

I have a folder that stores a couple of bool values, the folder is stored in ReplicatedStorage and I have a saving script that saves the values of the bool values, the problem is when I test the game and data works in studio btw, I have a shop and when I buy something the bool value of that specific item is set to true, then I leave the game, I rejoin and then find that all bool values are set to true and everything item is like "Equip" why is this happening when saving?

theres no error in the output, just prints that data got saved..

Serverscript: (saving script)

01-- Services
02 
03local DataStoreService = game:GetService("DataStoreService")
04 
05local ReplicatedStorage = game:GetService("ReplicatedStorage")
06 
07local TagData = DataStoreService:GetDataStore("Test1")
08 
09-- Folders
10 
11local nametagPurchases = ReplicatedStorage:WaitForChild("NametagPurchases")
12 
13local firstPage = nametagPurchases.FirstPage
14 
15local function getTags() -- A function that gathers all the Bool Values and are store in a table.
View all 81 lines...

pls help pls pls

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

The only thing I can see right now is that when you saving the data, you are only getting 1 piece of data and applying that same one to all the bool values, which is why they all have the same value. Due to this, you would need to create new data stores and name it uniquely to the exact value you want to apply it to, so that you don’t mix them up. Inside your for loop where you are doing “for _,boolvalue in pairs(firstPage:GetChildren()) do”, instead of taking each value and applying the same data, you can create a new data store for each boolvalue that’s in the table.

I believe this can be done somewhat like this:

1for _,boolvalue in pairs(firstPage:GetChildren()) do
2if boolvalue:IsA(‘BoolValue’) then
3local BoolData = DataStoreService:GetDataStore(boolvalue.Name, boolvalue.Value)
4boolvalue.Value = BoolData
5end
6end

Let me know if this doesn’t work or doesn’t match what you want. I’m a bit confused on this as well. ;)

Ad

Answer this question