Good evening, by making a script that allows to find a Ui directly without necessarily making variable, I told myself that it will be simple because it is necessary to take the descendants of playerGui except that I think that my code has itself a problem but I would not identify it
--Module
local manageModule = {}
function manageModule:FindUi(objectName)
for _, UiObject in playerGui:GetDescendants() do
print(UiObject)
if UiObject.Name == objectName then
return UiObject
else
return
end
end
end
return manageModule
--local
local frameFind = manageModule:FindUi("ScrollingObjectif")
The return statement inside the loop seems to be terminating the loop prematurely. If the first UiObject does not match the objectName, the loop will exit without checking any other objects.
-- Module
local manageModule = {}
function manageModule:FindUi(playerGui, objectName)
for _, UiObject in ipairs(playerGui:GetDescendants()) do
if UiObject.Name == objectName then
return UiObject
end
end
return nil -- If the object is not found
end