[ API Service ] v1.0.7a - A Utility ModuleScript for Roblox API Methods

I have a problem where when I do GetProperties(instance, true) it still returns non-writable properties which is a problem bc I only want the writable/scriptable ones

1 Like

Thank you for bringing this to my attention. It seems I only included the NotScriptable tag and not the ReadOnly tag. I’ve updated the module as well as the json database (if using the downloaded version).

amazing, thank you!

I really needed this for forever

bubu-dancing-dance

1 Like

I noticed a problem that it doesn’t recognized the colour or size properties for gui and parts. There’s also a few other writable values it doesn’t notice. Would be very much appreciated if this could be fixed! Thanks!

Could you list out which instances are specifically having this issue and with what properties?

Parts and any gui elements.

The Size, Colour, Material, and Position properties (What I need for parts) are not showing up in Readable or Writable properties.

For GUI elements, the Size, Position, and AnchorPoint are not showing up in Readable or Writable properties.

I’m unsure if there’s more that’s not showing up but those are what I noticed are missing and what I need. Much appreciated if you can fix it!

Could I see your code? All of those properties appear to show up fine for me, whether I pass an instance or a ClassName string.

An example usage would be something like:

local partProperties = API:GetProperties(workspace.Part) -- Table of properties [ Name : Value ]
print(partProperties)
Output
{
                    ["Anchored"] = true,
                    ["Archivable"] = true,
                    ["AssemblyAngularVelocity"] = 0, 0, 0,
                    ["AssemblyCenterOfMass"] = -6, 0.5, 8,
                    ["AssemblyLinearVelocity"] = 0, 0, 0,
                    ["AssemblyMass"] = inf,
                    ["AssemblyRootPart"] = Part,
                    ["AudioCanCollide"] = true,
                    ["BackParamA"] = -0.5,
                    ["BackParamB"] = 0.5,
                    ["BackSurface"] = Smooth,
                    ["BackSurfaceInput"] = NoInput,
                    ["BottomParamA"] = -0.5,
                    ["BottomParamB"] = 0.5,
                    ["BottomSurface"] = Smooth,
                    ["BottomSurfaceInput"] = NoInput,
                    ["BrickColor"] = Medium stone grey,
                    ["CFrame"] = -6, 0.5, 8, 1, 0, 0, 0, 1, 0, 0, 0, 1,
                    ["CanCollide"] = true,
                    ["CanQuery"] = true,
                    ["CanTouch"] = true,
                    ["CastShadow"] = true,
                    ["CenterOfMass"] = 0, 0, 0,
                    ["ClassName"] = "Part",
                    ["CollisionGroup"] = "Default",
                    ["CollisionGroupId"] = 0,
                    ["Color"] = 0.639216, 0.635294, 0.647059,
                    ["CurrentPhysicalProperties"] = 0.699999988, 0.300000012, 0.5, 1, 1,
                    ["Elasticity"] = 0.5,
                    ["EnableFluidForces"] = true,
                    ["ExtentsCFrame"] = -6, 0.5, 8, 1, 0, 0, 0, 1, 0, 0, 0, 1,
                    ["ExtentsSize"] = 4, 1, 2,
                    ["FormFactor"] = Brick,
                    ["Friction"] = 0.300000011920929,
                    ["FrontParamA"] = -0.5,
                    ["FrontParamB"] = 0.5,
                    ["FrontSurface"] = Smooth,
                    ["FrontSurfaceInput"] = NoInput,
                    ["LeftParamA"] = -0.5,
                    ["LeftParamB"] = 0.5,
                    ["LeftSurface"] = Smooth,
                    ["LeftSurfaceInput"] = NoInput,
                    ["LocalTransparencyModifier"] = 0,
                    ["Locked"] = false,
                    ["Mass"] = 5.599999904632568,
                    ["Massless"] = false,
                    ["Material"] = Plastic,
                    ["MaterialVariant"] = "",
                    ["Name"] = "Part",
                    ["Orientation"] = 0, 0, 0,
                    ["Parent"] = Workspace,
                    ["PivotOffset"] = 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
                    ["Position"] = -6, 0.5, 8,
                    ["ReceiveAge"] = 0,
                    ["Reflectance"] = 0,
                    ["ResizeIncrement"] = 1,
                    ["ResizeableFaces"] = Right, Top, Back, Left, Bottom, Front,
                    ["RightParamA"] = -0.5,
                    ["RightParamB"] = 0.5,
                    ["RightSurface"] = Smooth,
                    ["RightSurfaceInput"] = NoInput,
                    ["RootPriority"] = 0,
                    ["RotVelocity"] = 0, 0, 0,
                    ["Rotation"] = 0, 0, 0,
                    ["Shape"] = Block,
                    ["Size"] = 4, 1, 2,
                    ["SpecificGravity"] = 0.699999988079071,
                    ["TopParamA"] = -0.5,
                    ["TopParamB"] = 0.5,
                    ["TopSurface"] = Smooth,
                    ["TopSurfaceInput"] = NoInput,
                    ["Transparency"] = 0,
                    ["Velocity"] = 0, 0, 0,
                    ["archivable"] = true,
                    ["brickColor"] = Medium stone grey,
                    ["className"] = "Part",
                    ["formFactor"] = Brick,
                    ["shape"] = Block,
                    ["size"] = 4, 1, 2
}

Or if you just want to know what properties exist for a specific class:

local partProperties = API:GetProperties('Part') -- Array of properties
print(partProperties)
Output
{
                    [1] = "Anchored",
                    [2] = "Archivable",
                    [3] = "AssemblyAngularVelocity",
                    [4] = "AssemblyCenterOfMass",
                    [5] = "AssemblyLinearVelocity",
                    [6] = "AssemblyMass",
                    [7] = "AssemblyRootPart",
                    [8] = "AudioCanCollide",
                    [9] = "BackSurface",
                    [10] = "BottomSurface",
                    [11] = "brickColor",
                    [12] = "BrickColor",
                    [13] = "CanCollide",
                    [14] = "CanQuery",
                    [15] = "CanTouch",
                    [16] = "CastShadow",
                    [17] = "CenterOfMass",
                    [18] = "CFrame",
                    [19] = "className",
                    [20] = "ClassName",
                    [21] = "CollisionGroup",
                    [22] = "CollisionGroupId",
                    [23] = "Color",
                    [24] = "CurrentPhysicalProperties",
                    [25] = "CustomPhysicalProperties",
                    [26] = "EnableFluidForces",
                    [27] = "ExtentsCFrame",
                    [28] = "ExtentsSize",
                    [29] = "FormFactor",
                    [30] = "FrontSurface",
                    [31] = "LeftSurface",
                    [32] = "Locked",
                    [33] = "Mass",
                    [34] = "Massless",
                    [35] = "Material",
                    [36] = "MaterialVariant",
                    [37] = "Name",
                    [38] = "Parent",
                    [39] = "PivotOffset",
                    [40] = "Reflectance",
                    [41] = "ResizeableFaces",
                    [42] = "ResizeIncrement",
                    [43] = "RightSurface",
                    [44] = "RootPriority",
                    [45] = "Rotation",
                    [46] = "Shape",
                    [47] = "Size",
                    [48] = "SpecificGravity",
                    [49] = "TopSurface",
                    [50] = "Transparency"
}
function PlaceService.GetChilds(Parts)
	local PartsT = {}

	for i, instance in Parts do
		--print(Parts)
		if instance.ClassName then
			if not instance:IsA("Terrain") and not instance:IsA("Camera") then
				local Properties = {
					Readable = {},
					Writable = {},
					Location = "",
				}
				local prt = require(game.ReplicatedStorage.APIService):GetProperties(instance, true)
				local prt2 = require(game.ReplicatedStorage.APIService):GetProperties(instance, false)
				table.insert(Properties.Writable, prt)
				table.insert(Properties.Readable, prt2)
				table.insert(PartsT, Properties)
				Properties.Location = instance.Parent:GetFullName()
			end
		end
	end

	return PartsT
end

I’m getting the readable and writable properties seperate for each instance because I am saving it in a third-party database howerver it isn’t giving me the Size, Colour (Color if u’re American), ect

Hold up, I just tested it and it outputted the values so that means it’s getting lost somewhere in my code. Sorry abt that, it seems it’s an issue on my part!

1 Like

I found the problem but can’t seem to solve it. Whenever I encode my table into a JSON string using HTTP service, those properties get lost after I decode it and I’m unsure why. If you know why, lmk!

I found the issue, I think it’s cause I can’t save vector3 and enums in json string

If you look at the module, inside of APIService is a module called “References”. It has a method called JSONEncodeValue() which will convert most special value types into a format that works with JSON. It also has a method called JSONDecodeValue() to reverse that. Just use it on every value before you fully encode it with JSON, it’ll automatically check if it needs to be converted or not. Then do the reverse order when you need to by decoding JSON, and then using JSONDecodeValue() on each value.

It probably won’t convert every value type, but it converts these:

references.Constructors = {
	['Vector3']=Vector3,
	['CFrame']=CFrame,
	['Color3']=Color3,
	['Vector2']=Vector2,
	['Rect']=Rect,
	['UDim']=UDim,
	['PhysicalProperties']=PhysicalProperties,
	['Faces']=Faces,
	['ColorSequence']=ColorSequence,
	['NumberRange']=NumberRange,
	['NumberSequence']=NumberSequence,
	['UDim2']=UDim2,
	['BrickColor']=BrickColor,
	['Region3int16']=Region3int16,
	['Ray']=Ray,
	['TweenInfo']=TweenInfo,
	['Enum']=Enum
}

why does it have to be so hard to get all instance properties, ive read like 4 articles on the devfourm on this already… roblox just give us that one function

3 Likes

It’s awesome! It would definitely be very useful to create a server-side datastore for saving objects

1 Like

I’ve tried using this module, and I can’t do anything with it because API require is giving an error: “Module code did not return exactly one value API”. Maybe it’s happening only with me, I don’t really know.

I’d love to see this module with good typization and without issues.

Which version are you using? If you’re using the model version, make sure you’ve pasted the JSON code in the correct location. Could I also see what your script looks like that’s using this module?

(I’m heading off now, but I’ll answer back as soon as I can.)