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

What is the Child functions?

Asked by 7 years ago

Hello! I am a beginner to Roblox LUA and I was wondering how to use the findchildren and all the other functions.. I do not understand them. If you could pls give me a detailed paragraph. Tyvm!! :)

2 answers

Log in to vote
0
Answered by 7 years ago

If you mean functions like FindFirstChild() and WaitForChild() then I will explain though I'm not very good with FindFirstChild(). **FindFirstChild()** Finds the first child that is in the '()' for example it may be used for a line like script.Parent:FindFirstChild('Humanoid'). **WaitForChild()** is kinda the same deal except it is used in the game. For example, in the studio, everything may be working perfectly and yea but when you actually play the game things don't work out. That's because when you just make variables like local tool = game.ReplicatedStorage.Tool it's possible 'Tool' hasn't loaded yet, so we would use local tool = game.ReplicatedStorage:WaitForChild('Tool') this will wait for the child of ReplicatedStorage Tool to load.

If I helped then please accept answer :P

0
You helped me understand a portion of it! Tysm! Atleast i understand the point of their behaviors! :D iizWishzii 21 — 7y
0
Can you accept answer cause I helped? xD BlackOrange3343 2676 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

To find the children of something, you want to use the function GetChildren() that returns a table. For example, the script below gets all the children of the workspace.

wsChildren = workspace:GetChildren()

Each of these children maintain the same properties as they normally would, so to change the children of a certain model to transparent would be like below.

model = game.workspace.Model
for i,v in pairs(model:GetChildren()) do
    if v:IsA('BasePart') then -- checking that the part is actually a part
        v.Transparency = 1;
    end
end
0
Tysm!! I know about the For Loop, but can you please explain to me "In pairs" and v:IsA? iizWishzii 21 — 7y
0
Basically, the i and the v can be anything, but have to be separated with a comma and i is the current position, v is stored value, t is table. IsA is just asking 'Is the child a Part?'. If it is, the code will continue. shadow7692 69 — 7y
0
Tysmm! but how about the In Pairs? iizWishzii 21 — 7y
0
Since it returns a table, the In Pairs returns the key pairs of data. shadow7692 69 — 7y

Answer this question