How to perform a function to multiple objects?
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.
01 | local Button = script.Parent:WaitForChild( "Button" ) |
02 | local Frame = script.Parent |
05 | function debounce(func) |
06 | local isRunning = false |
18 | function isImage( Image ) |
19 | return Image:IsA( "ImageLabel" ) and Image:IsAncestorOf(Frame) |
24 | Button.MouseButton 1 Down:connect(debounce( function (func) |
26 | print ( 'Button pressed!' ) |
29 | local color 3 = Color 3. new |
30 | local vec 3 = Vector 3. new |
32 | local vec 3 toColor 3 = function (vec) |
33 | local newvec = vec 3 (vec.x/ 255 , vec.y/ 255 , vec.z/ 255 ) |
34 | return color 3 (newvec.x/ 255 , newvec.y/ 255 , newvec.z/ 255 ) |
37 | function color 3 toVec 3 (col) |
38 | return vec 3 (col.r* 255 , col.g* 255 , col.b* 255 ) |
41 | function tween_color(start_color,end_color,alpha) |
42 | local start = start_color |
43 | local endme = end_color |
44 | local startvec = color 3 toVec 3 (start) |
45 | local endvec = color 3 toVec 3 (endme) |
46 | return vec 3 toColor 3 (startvec:lerp(endvec,alpha)) |
50 | Image.ImageColor 3 = tween_color(color 3 ( 81 , 183 , 255 ),color 3 ( 36 , 79 , 113 ),i) |
54 | Image.ImageColor 3 = tween_color(color 3 ( 81 , 183 , 255 ),color 3 ( 36 , 79 , 113 ),i) |