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

How to perform a function to multiple objects?

Asked by 10 years ago

I am trying to tween the color of all ImageLabels that is a descendant of Frame. I would do GetAllChildren() however, there are other objects besides Image Labels in the Frame.

How would I reference ALL image labels in the Frame as one variable? That way I can easily perform actions to them.

01local Button = script.Parent:WaitForChild("Button")
02local Frame = script.Parent
03 
04 
05function debounce(func)
06    local isRunning = false    -- Create a local debounce variable
07    return function(...)       -- Return a new function
08        if not isRunning then
09            isRunning = true
10 
11            func(...)          -- Call it with the original arguments
12 
13            isRunning = false
14        end
15    end
View all 58 lines...

1 answer

Log in to vote
4
Answered by
LostPast 253 Moderation Voter
10 years ago

Use for i,v in pairs() do;

http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#pairs

Either put all of the parts you want in a table and use this loop on them or have all of the parts under one parent and use :GetChildren(). This loop checks all the posibilities and does what you want them to do.

like;

1for index,variable in pairs(Workspace:GetChildren()) do
2if variable:IsA("Part") then
3variable.Name = "LoppyMoney"
4end
5end

Hope this helps :)

Ad

Answer this question