A working DataStore that shows money in the .Text property of a TextLabel.
DataStore isn’t functioning. I have tried printing it rather than doing it directly to the textbox and I have not been successful.
(Both scripts are located in ServerScriptService)
Here is the PlayerAdded script:
game.Players.PlayerAdded:Connect(function(player)
local Cash = player:WaitForChild("PlayerGui").MainMenu.Inventory.CashAmount.Text
local Bank = player:WaitForChild("PlayerGui").MainMenu.Inventory.BankAmount.Text
local key = "player-"..player.UserId
local savedAmount = DataStore:GetAsync(key)
if savedAmount then
Cash = savedAmount[1]
Bank = savedAmount[2]
else
local toSave = {Cash, Bank}
DataStore:SetAsync(key, toSave)
end
end)
Here is the PlayerRemoving script:
game.Players.PlayerRemoving:Connect(function(player)
local Cash = player:WaitForChild("PlayerGui").MainMenu.Inventory.CashAmount.Text
local Bank = player:WaitForChild("PlayerGui").MainMenu.Inventory.BankAmount.Text
local key = "player-"..player.UserId
local toSave = {Cash, Bank}
DataStore:SetAsync(key, toSave)
end)```