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

Why doesn't my data store actually save the data?

Asked by 6 years ago
Edited 6 years ago

Alright so pretty much only one weapon saves and I'm not sure why. I've tried having multiple data stores so it would work but nothing happens and it still shows up as 0. You don't have to read the whole thing just know that the ones that don't work are the M1911, AWP and more but I forgot but still what's the matter or is there a more efficient way since my game will have a lot of different weapons.

001local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerWeaponStats")
002 
003game.Players.PlayerAdded:connect(function(player)
004 
005    local key = "user-" .. player.userId
006 
007    local store = DataStore:GetAsync(key)
008 
009        --AK-12
010        player.Class.WeaponStats["AK-12"].Kills.Value = store[1]
011        player.Class.WeaponStats["AK-12"].Headshots.Value = store[2]
012        player.Class.WeaponStats["AK-12"].BTs.Value = store[3]
013        player.Class.WeaponStats["AK-12"].DKs.Value = store[4]
014        player.Class.WeaponStats["AK-12"].LS.Value = store[5]
015 
View all 146 lines...

Their is more it's just I had to remove some.

0
It might be useful to learn how to implement a generic for loop in your situation. User#25115 0 — 6y
0
I don't get it GameBoyOtaku 63 — 6y
0
You had the patience to write all of this? User#24403 69 — 6y
0
Yes I did GameBoyOtaku 63 — 6y
View all comments (4 more)
0
use for loops yHasteeD 1819 — 6y
0
can I see an example please GameBoyOtaku 63 — 6y
0
thank you GameBoyOtaku 63 — 6y
0
Whys this have so many upvotes DinozCreates 1070 — 6y

Answer this question