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 |
03 | local DataStoreService = game:GetService( "DataStoreService" ) |
04 |
05 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
06 |
07 | local TagData = DataStoreService:GetDataStore( "Test1" ) |
08 |
09 | -- Folders |
10 |
11 | local nametagPurchases = ReplicatedStorage:WaitForChild( "NametagPurchases" ) |
12 |
13 | local firstPage = nametagPurchases.FirstPage |
14 |
15 | local function getTags() -- A function that gathers all the Bool Values and are store in a table. |
pls help pls pls
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:
1 | for _,boolvalue in pairs (firstPage:GetChildren()) do |
2 | if boolvalue:IsA(‘BoolValue’) then |
3 | local BoolData = DataStoreService:GetDataStore(boolvalue.Name, boolvalue.Value) |
4 | boolvalue.Value = BoolData |
5 | end |
6 | end |
Let me know if this doesn’t work or doesn’t match what you want. I’m a bit confused on this as well. ;)