How to reference instance created by Instance.New?

i want to rename and set the parent of a folder that is created by instance.new, but i have no idea how to do so

Instance.new() both creates the instance and returns the reference to it.

local folder = Instance.new(“Folder”)
folder.Name = “Some name”

1 Like

just set a local variale to it local a = Instance.new(“Folder”)

You can keep a multi-use reference with variables. You can keep a one-time-use reference without variables though.

Add default part to workspace:

Instance.new("Part").Parent = workspace

Create a MapSave folder and add it to ServerStorage

local NewFolder = Instance.new("Folder")

NewFolder.Name = "MapSave"
NewFolder.Archivable = false
NewFolder.Parent = game:GetService("ServerStorage")

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