Hi,
So right now I’m having an Issue where when I try to Load Data, It constantly fails, I’m not exactly sure what could be causing the Issue as I made sure to write the exact same way as I did in the other script I made (which worked).
WHAT HAVE I TRIED?
At First, I thought it was the Store Argument I added to the function(), But It didn’t seem to Cause any Issues to the Code so I ruled that out
I then checked if the GetStatus() function Returned incorrectly or if I was checking the wrong way, But again, It didn’t seem so.
I tried printing an Error which it did give me an error, so it does mean the code is working.
ERROR CODE?
I made sure to print if there was an Error, But it give me this: 502: API Services rejected request with error. Error code: 7 Reason: Studio access to APIs is not allowed.
Which is odd as my Game has Access to Data Store API,
(At this point I have explained this exact code so many times already)
GetStatus() function
This code just returns a Boolean, Just makes it faster to use:
-- Data Settings used for Getting/Saving Data
MaxAttempts = 3
Interval = 2
StudioSaves = true
-- function
function GetStatus()
return (RunService:IsStudio() and not StudioSaves or game.GameId == 0)
end
Loading Data function
function userData:LoadUserData(Store: DataStore)
if GetStatus() then return end -- Returns if Status is true
local Attempts = 1 -- Attempts
local Success, Data -- pcall Variables
repeat -- Loop
Success, Data = pcall(Store.GetAsync, Store, self.Key) -- pcall used
Attempts += 1 -- adds Attempt
if not Success then -- if not Success
task.wait(DataSettings.Interval)
warn(Data)
end
until Success or Attempts > DataSettings.MaxAttempts
if Success then -- if Successful (which is not)
if Data then -- if Data found
self.Data = Data -- Adds Data
print("Fetched Data for", self.Player) -- Prints Success
if self.Data.Other.Banned then -- If Banned
return self.Player:Kick(self.Data.Other.Reason)
end
else -- If No Data
warn("No Data Found for", self.Player) -- warns
end
else -- If Failed (which it did)
self.Player:Kick("Something went wrong Getting your Data!") -- Kicks player
end
end
The Admin in this post never actually confirmed when, if at all, this issue was fixed. This still happens to me aswell so as far as I am concerned it is not fixed.
-- Data Settings used for Getting/Saving Data
MaxAttempts = 3
Interval = 2
StudioSaves = true
-- function
function GetStatus()
return (RunService:IsStudio() and not StudioSaves or game.GameId == 0)
end
local userData = {}
function userData:LoadUserData(Store: DataStore)
if GetStatus() then return end -- Returns if Status is true
local Attempts = 1 -- Attempts
local Success, Data -- pcall Variables
repeat -- Loop
Success, Data = pcall(Store.GetAsync, Store, self.Key) -- pcall used
Attempts += 1 -- adds Attempt
if not Success then -- if not Success
task.wait(DataSettings.Interval)
warn(Data)
end
until Success or Attempts > DataSettings.MaxAttempts
if Success then -- if Successful (which is not)
if Data then -- if Data found
self.Data = Data -- Adds Data
print("Fetched Data for", self.Player) -- Prints Success
if self.Data.Other.Banned then -- If Banned
return self.Player:Kick(self.Data.Other.Reason)
end
else -- If No Data
warn("No Data Found for", self.Player) -- warns
end
else -- If Failed (which it did)
self.Player:Kick("Something went wrong Getting your Data!") -- Kicks player
end
end
return userData