- Whats the point of assigning data = myDataStore:GetAsync(UserID)
Will it error if I start doing the save data part?
- The reason I asked this question is because before I didn’t use to even do this, but my friend told me it’s better, but I don’t understand why.
local DataStoreService = game:GetService(“DataStoreService”)
local myDataStore = DataStoreService:GetDataStore(“myDataStore”)
local player = game.Players.PlayerAdded
player:Connect(function(plr)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = plr
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = leaderstats
local UserId = "Player_"..plr.UserId
local Data
local Succes,ErrorMessage = pcall(function()
Data = myDataStore:GetAsync(UserId)
end)
end)