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

How do I correctly DataStore variables?

Asked by
proo34 41
4 years ago
--Handels all values in player as well as save player data
--Variables
local DataStoreService = game:GetService("DataStoreService")

--Leaderstats
function added(player)
local ls = Instance.new("IntValue")
ls.Name = "leaderstats"

local TotalBricks = Instance.new("IntValue")
TotalBricks.Name = "Bricks"

local Cash = Instance.new("IntValue")
Cash.Name = "Cash"

--Other
local pr = Instance.new("IntValue")
pr.Name = "plrvalues"

local Multip = Instance.new("IntValue")
Multip.Name = "Multiple"

local PerBrick = Instance.new("IntValue")
PerBrick.Name = "PerBrick"

local CurrentBrick = Instance.new("IntValue")
CurrentBrick.Name = "CurrentBrick"

local PerCashOut = Instance.new("IntValue")
PerCashOut.Name = "PerCashOut"

local CashMultip = Instance.new("IntValue")
CashMultip.Name = "CashMultip"

local NumberOfBricksPerCash = Instance.new("IntValue")
NumberOfBricksPerCash.Name = "BricksPerCash"

--Connecter
ls.Parent = player
TotalBricks.Parent = ls
Cash.Parent = ls

pr.Parent = player
Multip.Parent = pr
PerBrick.Parent = pr
CurrentBrick.Parent = pr
PerCashOut.Parent = pr
CashMultip.Parent = pr
NumberOfBricksPerCash.Parent = pr

PerBrick.Value = 1
Multip.Value = 1
CurrentBrick.Value = 1
PerCashOut.Value = 20
CashMultip.Value = 1
NumberOfBricksPerCash.Value = 10
end
game.Players.PlayerAdded:connect(added)

I've been working on making this save but everything I do doesn't work, how can I do async correctly to save all this to a player?

1
close.. line 3 game:GetService("DataStoreService"):GetDataStore('Storage') greatneil80 2647 — 4y
0
use a table, save a table using SetAsync, load a table using GetAsync greatneil80 2647 — 4y
0
Nothing is happening because you haven't even used DataStoreService yet Ziffixture 6913 — 4y

Answer this question