So I'm trying to create a datastore with leaderstats and the leaderstats bit is working but I can't seem to get the data store to work. Here is my code
print("ji")
local DSS = game:GetService("DataStoreService")
local mydatastore = DSS:GetDataStore("Madata")
print("ye")
print(player)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = leaderstats
local UserId = "Player_"..player.UserId
local data
local success,errormessage = pcall(function()
data = mydatastore:GetAsync(UserId)
end)
if success then
Cash.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "player_"..player.UserId
local data = player.leaderstats.Cash.Value
local success,errormessage = pcall(function()
mydatastore:SetAsync(playerUserId,data)
end)
if success then
print("The data saved")
else
print("Therewasanerror")
warn(errormessage)
end
end)
game.Workspace.Script.Part.ClickDetector.MouseClick:Connect(function()
l
end)
Here are the errors I've got:
15:59:32.614 - Untitled Game auto-recovery file was created
ji
ye
nil
15:59:54.816 - Disconnect from 127.0.0.1|63779
Therewasanerror
15:59:54.835 - 502: API Services rejected request with error. HTTP 403 (Forbidden)
16:01:29.451 - ScriptNavigationHandler : No script currently available. (x2)
16:03:45.467 - Untitled Game auto-recovery file was created
Thank you for your help!

2 comments
Are API Services on? Are you testing in studio or in the Roblox Player?
Studio