DataStore Script Keeps failing?

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,

Here is Proof:

So now, I have no Idea what the Issue could be.


(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

Are you the owner of the place or is this a team create place?

does the working one was ingame or Studio

Bit of a Off Topic question, not really how DataStores work

But yes, I am the Owner in a Team Create Place

Both is where the issue is occurring.

No it is not off topic since there is a datastore issue if the person does not own the team create place

Not Exactly true,

As long as the game has access to the API, it works.

I made sure to test in a place I do not own, and Yes, It works (Alt Account, not actual person)

1 Like

It is completely true, so you are wrong.

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.

It’s still not my issue

Its also a group game so some of the things said dont really apply

Make sure you are actually reading the code.

you didn’t show the whole code though, you only showed the function and the GetStatus() function

Thats the code.

no it’s not, there isn’t

-- 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

I swear, you arent even reading.

i did read and mixed the code parts to reveal the code

Anyway, My Issue seemed to have fixed itself because I Rejoined the Game and its working now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.