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.
local Button = script.Parent:WaitForChild("Button")
local Frame = script.Parent
function debounce(func)
local isRunning = false -- Create a local debounce variable
return function(...) -- Return a new function
if not isRunning then
isRunning = true
func(...) -- Call it with the original arguments
isRunning = false
end
end
end
function isImage( Image )
return Image:IsA("ImageLabel") and Image:IsAncestorOf(Frame)
end
Button.MouseButton1Down:connect(debounce(function(func)
print('Button pressed!')
local color3 = Color3.new
local vec3 = Vector3.new
local vec3toColor3 = function(vec)
local newvec = vec3(vec.x/255, vec.y/255, vec.z/255)
return color3(newvec.x/255, newvec.y/255, newvec.z/255)
end
function color3toVec3(col)
return vec3(col.r*255, col.g*255, col.b*255)
end
function tween_color(start_color,end_color,alpha)
local start = start_color
local endme = end_color
local startvec = color3toVec3(start)
local endvec = color3toVec3(endme)
return vec3toColor3(startvec:lerp(endvec,alpha))
end
while true do
for i = 0,1,.1 do
Image.ImageColor3 = tween_color(color3(81, 183, 255),color3(36, 79, 113),i)
wait(.1)
end
for i = 1,0,-.1 do
Image.ImageColor3 = tween_color(color3(81, 183, 255),color3(36, 79, 113),i)
wait(.1)
end
end
end))
