local ds = game:GetService("DataStoreService")
local players = game:GetService("Players")
players.PlayerAdded:connect(function(player)
local userid = "user_"..player.UserId
local money_store = ds:GetDataStore("Money")
local money_stats = player:WaitForChild("leaderstats").Money.Value
local newmoney = money_store:GetAsync(userid)
print(newmoney)
player:WaitForChild("leaderstats").Money.Value = newmoney
end)
players.PlayerRemoving:connect(function(player)
local userid = "user_"..player.UserId
local money = ds:GetDataStore("Money")
local money_stats = player:WaitForChild("leaderstats").Money.Value
print(money_stats)
money:SetAsync(userid,money_stats)
end)
Why when loading data I get nil when I use print (newmoney)?

1 comment
Are you running this in studio? You'll have to enable studio API functions since it defaults to disallow datastores via studio