I have a datastore script that saves a players money for the next time they join their money is stored in ServerStorage.PlayerMoney.Playername This is the script i currently have
The script is in ServerScriptService and is a server side script.
local DSService = game:GetService('DataStoreService'):GetDataStore('Hamburger223232')
game.Players.PlayerAdded:connect(function(plr)
-- Define variables
print('waiting until tycoonscript ready')
wait(6)
print('Starting')
local uniquekey = 'id-'..plr.userId
local Moneystorage = game.ServerStorage:FindFirstChild('PlayerMoney')
local PlayerMoney = Moneystorage:FindFirstChild(plr.Name)
local savevalue = PlayerMoney.Value
--leaderstats.Name = 'leaderstats'
--savevalue.Parent = leaderstats
--savevalue.Name = 'Cash'
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
print('Loading data')
print(GetSaved)
print(GetSaved.Value)
savevalue = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
pcall(function()
DSService:SetAsync(uniquekey, NumbersForSaving)
end)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local Moneystorage = game.ServerStorage:FindFirstChild('PlayerMoney')
local PlayerMoney = Moneystorage:FindFirstChild(plr.Name)
local savevalue = PlayerMoney
local uniquekey = 'id-'..plr.userId
local Savetable = {savevalue.Value}
pcall(function()
DSService:SetAsync(uniquekey, Savetable)
end)
end)
This is the output in game. https://imgur.com/a/sPeBJ I set the money of my alt to 1000 then i let it rejoin but it still shows nil. How to make it output the money thats saved and give it to the player

2 comments
GetSaved is the table, so GetSaved[1] would be the value.
Thanks for this i managed to fix it now. I didn't understand where the value would be I thought it was in GetSaved.Value