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

How can I use class functions for :GetChildren()?

Asked by 2 years ago

I was told about classic functions for a tool that changes your Material and Colors, It also uses :GetChildren()

Can anyone tell me how to use class functions?

0
What do you mean? Sorry if I didn’t understand your question. Like what are you trying to achieve? Like changing the colors of all children? T3_MasterGamer 2189 — 2y

1 answer

Log in to vote
0
Answered by
ryanzhzh 128
2 years ago

It’s really simple. Luau’s syntax is really helpful. Let’s talk about how GetChildren works. It returns a table of the children, but it’s gonna be really hard to change any part in there, if roblox didn’t have in pairs(), it’s useless. So a simple loop can do it. Let’s name the target instance part: Instance. First let’s check if it’s a BasePart.

if part:IsA(“BasePart”) then

Then we can change it now, such as what you’ve seen in tools. —— FULL SCRIPT ——

for _, part: Instance in pairs(partParent:GetChildren()) do
        if part:IsA(“BasePart”) then
               -- your code
        end
end
Ad

Answer this question