Hello, I would like to know if someone could share example script to learn how to use parents and implement it in learning scripts that I will do now.
I have been learning to program in roblox for a month now and I have learned a lot but I have much more to learn and this is on my list, I would greatly appreciate it if you could share your knowledge with me, greetings.
Parents is what a child (Instance) is underneath and belongs to
-- code example:
local part = Instance.new("Part")
part.Parent = workspace -- the part will now appear under workspace because that's what it's parent is
local part2 = Instance.new("Part")
part.Parent = part -- the part will appear in workspace (because of descendants) but it's parent will be "part"
When using Instance.new or Instance:Clone, the object in question is parented to nil by default. nil means something has no value.
Instance.new can take a parent argument second (Instance.new("Part", workspace)) but if you care about performance then this isn’t recommended because Roblox has to constantly refresh the object after every time it’s used.