of     1   

AustinNally
#184112900Monday, February 22, 2016 12:53 AM GMT

Can someone help fix this script so it saves the two values. (Credits and Wins) right now it only saves one. WinsValue = 'PlayerScore' CreditsValue = 'PlayerScore' game.Players.PlayerAdded:connect(function(Player) local Leaderstats = Instance.new('Folder') Leaderstats.Name = 'leaderstats' Leaderstats.Parent = Player local Wins = Instance.new('IntValue') Wins.Name = 'Wins' Wins.Parent = Leaderstats Wins.Value = 0 local Credits = Instance.new('IntValue') Credits.Name = 'Credits' Credits.Parent = Player Credits.Value = 100 if Player:WaitForDataReady() then Player.leaderstats.Wins.Value = Player:LoadNumber(WinsValue) Player.Credits.Value = Player:LoadNumber(CreditsValue) end end) game.Players.PlayerRemoving:connect(function(Player) if Player:FindFirstChild('leaderstats') then Player:SaveNumber(WinsValue, Player.leaderstats.Wins.Value) Player:SaveNumber(CreditsValue, Player.Credits.Value) end end)
Aethex
#184113067Monday, February 22, 2016 12:55 AM GMT

Why are you using DataPersistence? I recommend reading up on DataStores: http://wiki.roblox.com/index.php?title=Data_store
AustinNally
#184113307Monday, February 22, 2016 12:59 AM GMT

The wiki doesn't help me with this stuff... It's hard for me to understand.
AustinNally
#184113722Monday, February 22, 2016 1:06 AM GMT

Would this work? local DataStore = game:GetService('DataStoreService'):GetDataStore('WinValue', 'CreditValue') local Key = "user_" .. Player.userId DataStore:UpdateAsync(Key, function(WinValue, CreditValue) local SavedWins = WinValue or 0 local SavedCredits = CreditValue or 100 return SavedWins, SavedCredits end)
Aethex
#184113975Monday, February 22, 2016 1:09 AM GMT

You can't use GetDataStore() to access two values at once. The second parameter of it is for the scope, not another value.
AustinNally
#184114030Monday, February 22, 2016 1:10 AM GMT

How do I do two values then?
Aethex
#184114123Monday, February 22, 2016 1:12 AM GMT

With two different variables.
AustinNally
#184114334Monday, February 22, 2016 1:15 AM GMT

Um. do you mean something like this local DataStore = game:GetService('DataStoreService'):GetDataStore('WinValue') local DataStore2 = game:GetService('DataStoreService'):GetDataStore('CreditValue') local Key = "user_" .. Player.userId DataStore:UpdateAsync(Key, function(WinValue) local SavedWins = WinValue or 0 return SavedWins end) DataStore2:UpdateAsync(Key, function(CreditValue) local SavedCredits = CreditValue or 100 return SavedCredits end)
Aethex
#184129299Monday, February 22, 2016 5:08 AM GMT

Yes.

    of     1