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

I have a question about DataStores? Its changing the values when you rejoin?

Asked by 8 years ago

Alright so the data store is supposed to save all your data and Im making a test with it to were if the Boolean is true then I need it to fire the if statement, but instead whenever you join, all your data is completely changed. You can see what I mean here, Only used the lemonade one, its supposed to save your data how it is and reload it but instead it changes the values. Just use if for a few seconds then rejoin and you'll know what I am talking about. Link to game Heres the if statement. As you can tell, its supposed to put all your values back in the same place

01if(saves.saveLemonade.Value == true) then
02        plr.PlayerGui.Game.Frame.Lemonade.Buy.Visible = false
03        plr.PlayerGui.Game.Frame.Lemonade.MakeCash.Visible = true
04        plr.PlayerGui.Game.Frame.Lemonade.Upgrade.Visible = true
05        plr.PlayerGui.Game.Frame.Lemonade.MakeCash.MPC.Value = saveLemonadeCPC.Value
06        plr.PlayerGui.Game.Frame.Lemonade.MakeCash.WaitTime.Value = saveLemonadeWaitTime.Value
07        plr.PlayerGui.Game.Frame.Lemonade.Upgrade.Level.Value = saveLemonadeLevel.Value
08        plr.PlayerGui.Game.Frame.Lemonade.Upgrade.UpgradeCost.Value = saveLemonadeUpgradeCost.Value
09        plr.PlayerGui.Game.Frame.Lemonade.CPC.Visible = true
10        plr.PlayerGui.Game.Frame.Lemonade.Level.Visible = true
11        plr.PlayerGui.Game.Frame.Lemonade.WT.Visible = true
12        plr.PlayerGui.Game.Frame.Lemonade.CPC.Text = "Cash Per Click: "..saveLemonadeCPC.Value
13        plr.PlayerGui.Game.Frame.Lemonade.Level.Text = "Level: "..saveLemonadeLevel.Value
14        plr.PlayerGui.Game.Frame.Lemonade.WT.Text = "Wait Time: "..saveLemonadeWaitTime.Value.." Second"

Heres the full data store code.

01local DSService = game:GetService('DataStoreService'):GetDataStore('AdVentureCapOfficialDataStore')
02game.Players.PlayerAdded:connect(function(plr)
03    local uniquekey = 'id-'..plr.userId
04    local leaderstats = Instance.new('IntValue', plr)
05    leaderstats.Name = 'leaderstats'
06    local saves = Instance.new('IntValue', plr)
07    saves.Name = "saves"
08    local savevalue =  Instance.new('NumberValue')
09    savevalue.Parent = leaderstats
10    savevalue.Name = 'Cash'
11    savevalue.Value = 1
12    local saveLemonade = Instance.new('BoolValue')
13    saveLemonade.Name = "saveLemonade"
14    saveLemonade.Parent = saves
15    local saveLemonadeLevel = Instance.new('IntValue')
View all 91 lines...

Please don't downvote this as I tried to supply enough information as I could

0
Solved it! dotProgram 0 — 8y

Answer this question