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

Datastore not saving GetSaved[3] but is saving GetSaved[2] and [1]? [closed]

Asked by
Envoked -11
6 years ago

So, The datastore saves "Money" and "abillity" but not "swordtype" and I cant figure out why. Its in serverscriptservice take a look at the script:

local DSService = game:GetService('DataStoreService'):GetDataStore('Envoked420')
game.Players.PlayerAdded:connect(function(plr)
 -- Define variables
 local uniquekey = 'id-'..plr.userId
 local leaderstats = Instance.new('Folder', plr)

 local Money =  Instance.new('IntValue')
local abillity = Instance.new("StringValue")
local swordtype = Instance.new("IntValue")
 leaderstats.Name = 'leaderstats'
 Money.Parent = leaderstats
 Money.Name = 'Money'
swordtype.Parent = leaderstats
swordtype.Name = 'SwordType'
abillity.Parent = leaderstats
abillity.Name = 'Abillity'

 -- GetAsync
 local GetSaved = DSService:GetAsync(uniquekey)
 if GetSaved then
 Money.Value = GetSaved[1]
abillity.Value = GetSaved[2]
swordtype.Value = GetSaved[3]
 else
  local NumbersForSaving = {Money.Value,abillity.Value,swordtype.Value}
  DSService:SetAsync(uniquekey, NumbersForSaving)
 end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Money.Value, plr.leaderstats.Abillity.Value, plr.leaderstats.SwordType.Value}
DSService:SetAsync(uniquekey, Savetable) 


end)
0
This is alvinbloxx's script. Make your own script. User#19524 175 — 6y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?