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

Help with Data Store?

Asked by 10 years ago

This data store is supposed to save bool values inside a model called WeaponUpgrades. There are 8 boolValues total, yet this script only seems to be saving two of them. Can anyone help me figure out why?

game.Players.PlayerRemoving:connect(function(Player)
local DataStore = game:GetService("DataStoreService"):GetDataStore(Player.userId.. "Weapons");
local statsStorage = Player:FindFirstChild("WeaponUpgrades"):GetChildren()
for i = 1, #statsStorage do wait()
DataStore:SetAsync(statsStorage[i].Name, statsStorage[i].Value) 
end
end)

game.Players.PlayerAdded:connect(function(Player)
local DataStore = game:GetService("DataStoreService"):GetDataStore(Player.userId.. "Weapons")
Player:WaitForChild("WeaponUpgrades")
wait()
local stats = Player:FindFirstChild("WeaponUpgrades"):GetChildren()
for i = 1, #stats do wait(.1)
stats[i].Value = DataStore:GetAsync(stats[i].Name)
end
end)
0
I'm not sure what your problem is, but you don't really need to save it inside of a model, you can save it under a Key. Look up Data Persistence on the Wiki. If this isn't what you mean, then ignore this, just giving ideas. SlickPwner 534 — 10y

Answer this question