Im trying to get my data store script in server script service to work but its not??
Asked by
8 years ago Edited 8 years ago
Im trying to get my data store script to work but there where 0 errors and it did not work any idea why?
It also keeps all stats at 0.
01 | local datastore = game:service( "DataStoreService" ):GetDataStore( "OG-OMDA" ) |
03 | game.Players.PlayerAdded:connect( function (p) |
04 | local ls = Instance.new( "IntValue" , p) |
05 | ls.Name = "leaderstats" |
07 | local Coins = Instance.new( "IntValue" , ls) |
10 | local Lvl = Instance.new( "IntValue" , ls) |
13 | local XP = Instance.new( "IntValue" , ls) |
16 | local Diamonds = Instance.new( "IntValue" ,ls) |
17 | Diamonds.Name = "Diamonds" |
19 | XP.Changed:connect( function () |
20 | Lvl.Value = math.floor(XP.Value / 500 ) |
22 | local k = datastore:GetAsync(p.Name.. "key" ) |
29 | datastore:SetAsync(p.Name.. "key" , { Coins.Value,Lvl.Value,XP.Value,Diamonds.Value } ) |
33 | game.Players.PlayerRemoving:connect( function (p) |
34 | local st = { p.leaderstats.Coins.Value,p.leaderstats.Lvl.Value,p.leaderstats.XP.Value,p.leaderstats.Diamonds.Value } |
35 | datastore:SetAsync(p.Name.. "key" ,st) |
Please help.