Log in to vote

How Can I Use This Data Store To Find A Player Value? [closed]

Asked by 10 days ago
Edited 10 days ago

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 ="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)
    if success then
        playerMoney[player] = money
        playerNotificationEvent:FireClient(player, "Error retrieving saved data: please try again later")



Closed as Not Constructive by incapaz

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?