Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hi, what does Parent, FindFirstChild and Children means? What effect do They have.

Asked by 4 years ago

What does Parent, FindFirstChild and Children means? What effect do They have.

2 answers

Log in to vote
1
Answered by
NotedAPI 810 Moderation Voter
4 years ago
Edited 4 years ago

Parent is like where they part is or whats before the part. So if we had a ScreenGui and inserted a frame within that ScreenGui the parent would be ScreenGui.

FindFirstChild is useful is many ways. You use this when you want to find the first child of a part. Ex. workspace:FindFirstChild("Part"). This will find the first child within workspace named part.

GetChildren is used when you want to get all the children of something. Ex. workspace:GetChildren(). This will get all the children within workspace.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Sometimes, such as when you're getting some part from a player, you would use FindFirstChild(). The reason why is because using just a . would do it instantly find a child, and not try again. FindFirstChild() would keep searching until the arguement inside of the brackets is found.

Take example:

local character = game.Players.LocalPlayer.Character
local HumaniodRootPart = character.HumanoidRootPart

If your script was like this, then the output would say something related to: HumanoidRootPart is not a child of game.Players.LocalPlayer.Character. To fix that, you would use the FindFirstChild()

Here's the fixed example:

local character = game.Players.LocalPlayer.Character
local HumaniodRootPart = character:WaitForChild("HumanoidRootPart")

Hope you understand mate! Have an amazing day :D

Answer this question