-
What do you want to achieve? Keep it simple and clear!
a table datastore -
What is the issue? Include screenshots / videos if possible!
it gave me a 404 error when i called the datastore, now without modifying the code at all, its giving me a “Access forbidden”
the issue appears to be in the saving area, not the loading area, however i included both parts of the script.
current error:
Old 404 error:
-
What solutions have you tried so far? Did you look for solutions
I’ve looked for solutions on YT, and devforum, however i haven’t seen any solutions that work
script:
local dataStoreService = game:GetService("DataStoreService")
local DataStore = dataStoreService:GetDataStore("MyDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats2 = Instance.new("Folder")
leaderstats2.Name = "leaderstats2"
leaderstats2.Parent = player
local loads = Instance.new("NumberValue")
loads.Name = "Loads"
loads.Value = 0
loads.Parent = leaderstats2
local playerkey = player.UserId..player.Name
wait(3)
-- Loading Data
local LoadsData
local success, errormessage = pcall(function()
LoadsData = DataStore:GetAsync(playerkey)
end)
if success then
loads.Value = LoadsData
end
end)
game:BindToClose(function()
for _, player in pairs(game.Players:GetPlayers()) do
local playerId = player.UserId..player.Name
local tableSaved = {}
-- Saving loads
local loadsValue = player.leaderstats2.Loads.Value
table.insert(tableSaved, 1, loadsValue)
table.insert(tableSaved, 2, loadsValue + 300) -- for testing)
local success, errormessage = pcall(function()
DataStore:SetAsync(playerId, tableSaved)
end)
end
end)