Hello! I was looking on the Developer Wiki at the data store page and I have a question. Using this data store script I found on the wiki, how would I be able to check the player's amount of money? Not sure how to go about data stores yet but how can I do something as simple as print(playerMoney) using this data store script from the wiki?
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local playerMoneyStore = DataStoreService:GetDataStore("PlayerMoneyStore")
local playerNotificationEvent = Instance.new("RemoteEvent")
playerNotificationEvent.Name = "PlayerNotificationEvent"
playerNotificationEvent.Parent = ReplicatedStorage
local playerMoney = {}
local function onPlayerAdded(player)
local playerId = tostring(player.UserId)
local success, money = pcall(function()
return playerMoneyStore:GetAsync(playerId)
end)
if success then
playerMoney[player] = money
else
playerNotificationEvent:FireClient(player, "Error retrieving saved data: please try again later")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
