I am trying to make a player dataStore script, this has not been working for a while and now I am just now getting to it, can someone help?
local DataStoreService = game:GetService("DataStoreService")
local MoneyDataStore = DataStoreService:GetDataStore("MoneyDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue",leaderstats)
money.Name = "Money"
money.Value = 0
local MoneyData
local success,err = pcall(function()
MoneyData = MoneyDataStore:GetDataStore("plr: "..plr.UserId)
end)
if success then
print("Loaded player data.")
money.Value = MoneyData
else
print("Error loading data.")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success,err = pcall(function()
MoneyDataStore:SetAsync("plr: "..plr.UserId,plr.leaderstats.Money.Value)
end)
if success then
print("Saved player data.")
else
print("Error while saving player data.")
end
end)

3 comments
there was no output error other than: 502: API Services rejected request with error. HTTP 403 (Forbidden). And it's still not working
Enable API Services in your game.
i did