---
# System prepended metadata

title: PID - 1185

---




# GDScript Difference between new() and instance()

:::info
 GDScript is a high-level,object-oriented and gradually typed programmming language built for game engine Godot.
:::

## Information
In GDScript, `new()` and `instance()` are two methods used to create new instances of a class or a scene.

## :small_blue_diamond: new()

 **Example**

:::success
var my_class_instance = MyClass.new()
:::
The new()creates a new instance of a class, 
When new() is called on a class, it creates a new instance of the class and returns it.This instance is not connected to any scene, and it does not have any children.
 
 :::success
 class MyClass:
   func hii():
  print("hello")
 var my_class =MyClass.new()
 my_class.hii()
 :::
 

## :small_blue_diamond: instance()
**Example**
:::success
var my_scene_instance = load("res://MyScene.tscn").instance()
:::

when instance() is called on a scene, it creates a new instance of the scene and returns it. This instance is a copy of the original scene, including all of its nodes and their properties. 

:::success
var instance = scene.Instantiate();
AddChild(instance)

:::



### Key-Points:
The instance() creates a new instance of a scene every time it’s called, if you call instance() multiple times on the same scene, you will get multiple independent instances of that scene.

While new() creates a new instance of a class every time it’s called, when you call new() multiple times on the same class, you will get multiple independent instances of that class, but they will not be connected to each other in any way. 
 :::spoiler  Difference between new() and instance() 
There is a minor but important difference between the two,
1.new create a new instance of the class. It will creates a node of the type the class extends,will return that node.
2.instance create a new instance of scene,which includes the class or subresources(nodes,textures etc).

:::
