I was trying to get all of the properties of a part (without HTTPService).
I don’t need it for something specific, just testing.
I thought to myself if ModuleScripts are just tables, and I can loop through them and see what’s in them. Can I do the same with Instances (Since module scripts are just tables)?
Basically, if an Instance (like part) was just a table (Like module scripts), I would be able to loop through the table.
But I got the Exception: (table expected, got Instance) as I expected, but isn’t Instance a table?
If not, what is it then? Lua doesn’t have a keyword like classes, OOP is done by tables and metatables.
So, Instance is something else, not a table, so I thought of Java (another language I know a bit of).
You can’t loop through a Java class, only through an Array (or Vector, ArrayList, etc).
All of the private variables remain hidden. Is it the same case here? The Instance is programmed by another language that contains classes (or something similar) and everything (like private variables) remains private?
Are Roblox and the Instance programmed by another language? Is there a way to get the properties of an Instance without a Service or something external?
One thing I am sure about, Instance doesn’t exist in pure Lua (outside of Roblox).
Thanks for answering, I might have reached the wrong conclusions , just let me know
Roblox is programmed in C++.
Lua is an embedded language which essentially means it allows other users to interact with their program. Lua: an extensible embedded language
I think this function will be able to do what you want, just it hasn’t been released yet.
I think this module might be able to do what you want:
Wouldn’t a dictionary with classnames as keys attached to dictionaries with property names would be more efficient rather than checking for 200 properties at once with a loop?
it wont be looping. Ive effectively bypassed the limit of locals I can use so I can pcall for each property. It is very fast at getting all properties and does not require looping.
But making a dictionary wont really work as you cant pull the names of properties only the values. And you cant really tell what is what as many use the same values like Vector3 for Velocity and Position.
you could try to use a dictionary but it wouldn’t be as fast or worth the time. It would end up with a bunch of nils or errors.
Attributes are essentially user generated properties. They won’t give you a list of all the part’s properties, just the ones that you’ve created using SetAttribute.
At current pretty much.
It would be a bit like a dictionary really.
{
[“Name”] = “Part”,
[“Size”] = Vector3(2,1,4)
}
However this is locked in by roblox so the property table cannot be edited. A read only copy would be helpful but this is more of a discussion that should be had on feature requests.
Instances are just userdatas with a metatable, not really a table. You can’t use rawset or rawget on them, so it really isn’t right to call them tables