Why isn't this loop working

How come this code won’t work? I loop through all the screen gui’s in the playergui and put Enabled to false, however it doesn’t seem to work and I don’t know why? This code is for a loading screen and I want to disable all other UI elements while its loading.
image


As you can see the money, kills and wins UI elements are still Enabled!

Try:

for _, UIs in pairs(playerGui:GetChildren()) do

    if v:IsA('ScreenGui') and v.Name ~= 'LoadingScreen' then
       v.Enabled == false
    end

end

No it didn’t change anything, all the ui are still there and no errors pop up

What is the code prior to the snippet you provided? Did you get anything in your output, too? Are there any scripts interfering with this one?

Edit: Try adding a print statement in that snippet of code. See if the script is detecting the GUIs. Maybe the GUIs have not loaded before you called PlayerGui:GetChildren().

Can you show me the explorer and show me the whole script?

Sorry I just got off but it’s a local script under replicatedfirst and in it is a screen gui called loading screen that I then clone into the starter gui. In starter gui there’s only a screen gui with the money and kills and wins

Ok, can you show me where you put that block of code in your script?

Can you like set the enable to false of the screen gui with the money and kills and wins in the property instead set it to false in the script??

Is there a reason you are disabling GUI’s rather than just making the loading screen have a higher ZIndexs so that it renders above all other elements?

EDIT: If you use multiple ScreenGUIs make sure you change the ScreenGUIs ZIndexBehavior to Global instead of Sibling.

1 Like

This will work and helpful too!!

Wait sorry what do you mean by that? where is the zindexes property? EDIT: Oh I found it, but the problem is that my loading screen is in a separate gui than the others so it doesn’t work

Change all the ScreenGUI’s ZIndexBehavior to Global. Then they will share ZIndex values between ScreenGUI’s.