Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"GetChildren" method not finding things in workspace?

So basically I have a folder in the Work space full of stuff and I need to get the children so I can work on it much more faster. script I don't know if I made a grammar mistake or something it would be cool if someone helped :)

parts = game.Workspace.Shirts.GetChildren()
part.Parent = char

1 comment

2

You should really consider opening your output and looking at errors. It saves us from answering trivial issues like this.

1 answer

✓ Accepted answer

You didn't call the function correctly. You indexed it, which is still calling it, but you need to reference the object again if you're doing it that way.

You have to think of object-based functions in roblox the same way you'd look at a table and it's contents.

example;

local Part = { --This is the object
	Size = Vector3.new(1,1,1); --These are the properties
	CFrame = CFrame.new(0,0,0);
	BrickColor = BrickColor.new("Really red");
	GetChildren = function(self) --This is an object-based function
		--code
	end
}

What you're doing is referencing the 'GetChildren' function by indexing it: workspace.Shirts.GetChildren()

Since you're doing it this way, the 'self' parameter shown in the example is never given. You have to provide it manually.

parts = workspace.Shirts.GetChildren(workspace.Shirts)


The most common way to call the function, is to "invoke it as a method" - as eLunate stated in the comments. To do this, you use a colon(:) to reference the function. This way, you don't need to manually provide the 'self' parameter.

parts = workspace.Shirts:GetChildren()

2 comments

2

He did call it, he just didn't invoke it as a method.

0

Oh..Foolish of me okay thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.