Is There an API That Retrieves Data From a Game?

Okay so basically what I’m asking is if there is a method in the Roblox API that allows you to get data from a game.

Like let’s say I have a baseplate and a random red part in the game.

I’d assume that it would be an AssetService method.

When I call the API, it would probably return something like:

local Data = the method here

print(Data)
-- it prints out:
[“Baseplate”] = {
-- properties I’m too lazy to write
},
[“MySuperCoolPart”] = {
[“Name”] = “MySuperCoolPart”,
[“ClassName”] = “Part”,
[“BrickColor”] = “Really red”
}
4 Likes

If they did, then I’m pretty sure game’s can easily get stolen. Needless to say, it would mean that all games aren’t secured from any exploitation. So, I doubt there’s an API for that type of stuff.

Why would you want a function like this anyway? The main question would be what are you trying to accomplish?

2 Likes

I’m tryna have something in game that would load a players’ game and basically have a version of it inside the game.

1 Like

Yeah I’d just need the basic properties of it like the color of something, the name, and the parent and maybe the position.

1 Like

So, like saving the information in that server into a dictionary that can be used from another place in the same game?

So like, let’s say there was an API of that sort, and you save its information like this:

local GameDataService = game:GetService("GameDataService") -- this is a fake service, please don't actually try to get this service (for those who's looking for the same answer)
GameDataService:SaveGameData() -- saves the place data in the game's local cloud

And you can load it onto a place that shares the same game as that place:

local GameDataService = game:GetService("GameDataService") -- this is a fake service, please don't actually try to get this service (for those who's looking for the same answer)
local otherPlaceData = GameDataService:LoadGameDataById(universeId) -- loads the game with the specified universeId from the game's local cloud

Is this what you’re trying to achieve?

1 Like

Yes this is very close but instead of saving stuff I just need to get data from a game. There are already methods in the API for saving and publishing games it’s AssetService:CreatePlaceAsync and AssetService:SavePlaceAsync.

I just need to get the data from a game similar to a HTTP request.

I’m 95% sure there are no methods for this but maybe there is and that’s why I created this post

28 minutes dedicated to a response… props to you :saluting_face:

1 Like

Well, you do have to save that information in order to get it if you want to access it from a different place. You could then take it off [the game’s cloud, like in the example] after you successfully loaded it in. Or maybe you’d just want to get that information while in the same place that has the information, then you might want something like this:

local GameDataService = game:GetService("GameDataService") -- this is a fake service, please don't actually try to get this service (for those who's looking for the same answer)
local otherPlaceData = GameDataService:GetGameData() -- returns the current place's data with the instances properties stored as arrays, in an array.

But, to answer your question, it is possible to script. It’s just a little harder to create, in my opinion. Of course, you’d want to make a module fore this if you’re planning on using its functions more than once, but there are a few approaches to this. If you just want to get the current game’s data without getting it from another place, you don’t need to read the last two approaches.


If you just want a specific instance’s information, you can just get that instance and get its properties from there and put that information into an array. Then just

-- example:
local MyBrick = workspace:FindFirstChild("Bob The Brick")
local MyBricksDictionary = {}
MyBricksDictionary.BrickColor = MyBrick.BrickColor
MyBricksDictionary.Name = MyBrick.Name
MyBricksDictionary.Size = MyBrick.Size
MyBricksDictionary.CFrame = MyBrick.CFrame

If you want to get all the instances, it’s the same thing as getting one instance. Except, you would have to loop through the workspace’s children and store them. I say in the workspace, since in your example, it looks like you just want to get the instance that’s a descendant to the workspace.

-- example:
local WorkspaceDictionary = {}

local function InstanceToArray(instance)
	local InstanceDictionary = {}
	InstanceDictionary.Name = instance.Name
	InstanceDictionary.ClassName = instance.ClassName
	-- and you can just add other properties
	-- ideally, you'd check what type of instance it is, but in this example, it doesn't
	return InstanceDictionary
end

for _, instance in workspace do
	WorkspaceDictionary[instance.Name] = InstanceToArray(instance)
end

print(WorkspaceDictionary)

Now, you also might not want to do the instance class checking and doing the properties, to which would be an easy way of making your script 2000+ lines long since there’s a lot of classes. But, there’s a better way of doing that. You can just use HTTPService to get the properties of that specific instance, which you can convert the properties into an array of strings. Thankfully, someone already done that here. (You can choose to follow the tutorial, but the main code is most likely in there. They also have a version of where it doesn’t include HttpService here)

And, with that being the case, the InstanceToArray function would look more like this:

local GetProperties = require(module.to.property.loader)

local function InstanceToArray(instance)
	local InstanceDictionary = {}
	
	for _, property in GetProperties(instance.ClassName) do
		InstanceDictionary[property] = instance[property]
	end
	
	return InstanceDictionary -- wow, only 6 lines to code!!!1!11!
end

And there you have it, a way of storing the game’s information into a table for you to use!

Now, if this is not what you were looking for and wanted a way of getting the information outside that game, then you would have to do some exploring with DataStoreService or HttpService. (if you want to store the information outside the game, which would be more advanced) But, I do hope this very long essay helped out!

(And if it does help, make sure to mark it as the solution ^^)

1 Like

Although this is not the exact thing I’m looking for, I can tell you’ve spent a lot of time and this might be helpful to someone else!

The thing is that this would go thru the parts in the current game, I wish I could send a feature request, oh well

You deserve this solution. Consider it an honorary award! :saluting_face:

1 Like

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