Can someone give a detailed explanation of what an instance is?

Hello there. I am a somewhat intermediate scripter that is constantly wanting to learn new concepts. However, I need help on understanding what an instance is.

I know that ``Instance.new() creates a new thing but in stuff like the Roblox API, they use the word “instance” in complicated ways that I only partially understand.

I have tried to look up the meaning of the word used in this context but I can’t find anything.

Can someone please give me a detailed explanation of what an instance truly is?

4 Likes

An Instance is basically an object in a roblox game. Everything inherits properties and functions from the Instance base class. For example, Parts, Scripts, and Services, are all Instances because they inherit it from the Instance class and they’re viewable in the explorer. Instance.new doesn’t allow developers to create all Instances, some of them can only be created by core scripts because of security reasons.

You could look at the API Page on the developer hub: Instance | Documentation - Roblox Creator Hub

6 Likes

More generally in programming, an “instance” is a specific object of some class.

Like, you might have a class “Dog”. Your pet Woofers is an instance of that class “Dog”, with its name, breed, etc. assigned to that one thing.

4 Likes

I view most of roblox’s instances as tables… Tables with values and methods!

local BasePart = {}

BasePart.Transparency = 1

function BasePart:GetFullName()
  return ...
end

But thats my custom way on viewing it.
I know that roblox creates a blank object and then writes and assigned its properties and methods that you can call onto the object itself.
However, if you want to know how and what an instance is you’d have to understand the c++ side of roblox and get to understand how they create and manage these objects

1 Like

@HugeCoolboy2007 is pretty much correct, you can check a YouTube video on it, there’s only so much we can do when typing here, try the Developer hub, also you can check in studio by going into the object browser in the view tab I think

1 Like

Unfortunately you may leave disappointed with the information we gave you. There is actually not much we can find except what is on the API Documentation, the occasional piece of data on Luau’s Github IO and such. We can also draw conclusions from programming in general, but that is not that helpful.

Ah I see now! Thank you very much.

That example helped me understand

Actually I understood it with @HugeCoolboy2007 's explanation and @nicemike40 's example. At first I didn’t quite get it with the just the API documentation but now I have a wider understanding of instances.

1 Like