I have tried numerous ways to get it to work, unsure if it is a bug or not but can someone help me please The error I keep receiving is 19:29:22.015 - 502: API Services rejected request with error: HTTP 0 (HTTP 403 (HTTP/1.1 403 Forbidden)) Here is the script if you want to have a look at it.
local data = game:GetService("DataStoreService")
local datastore = data:GetDataStore("RebornDataInitialiser")
game.Players.PlayerAdded:Connect(function(player)
local userid = tostring(player.userId)
local data1 = Instance.new("Folder")
data1.Name = "Data"
data1.Parent = player
local xp = Instance.new("IntValue")
xp.Name = "XP"
xp.Value = 0
xp.Parent = data1
local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 0
level.Parent = data1
local saving = datastore:GetAsync(userid)
if saving then
level.Value = saving[1]
xp.Value = saving[2]
else
local plr_data = {level.Value, xp.Value}
datastore:SetAsync(userid, plr_data)
game.Players.PlayerRemoving:Connect(function(player)
local id = tostring(player.userId)
local plr_data2 = {player.Data.Level.Value, player.Data.XP.Value}
datastore:SetAsync(id, plr_data2)
end)
end
end)

6 comments
Actually, you can type userId as of now and it still works.
But, it is deprecated so it would be best to start using UserId
Make sure the API Services are enabled first. You can check this if you go to the game settings and enable "Enable Studio Access to API Services"
I have already
legends say the datastore refuses to load data to this day.
Make sure that it is your game, make sure you have internet, etc