SurfaceGui Layering Problem

As you can see in the video, the scroll wheel GUI only works on the first one, as do the face buttons. I’m unable to click them as the hair GUI is in the way. The FacesGUI does not work. I don’t know how to fix this. I tried making a script that puts the hair GUI in ReplicatedStorage and pulls it out when it’s hair time, and vice versa. If anyone knows how to fix this, please help me.

local CurrentSetting = game.Workspace.Lobby.ScriptedObjects.MasterCCDisplay.CurrentSetting

--Next Button

local NextButton = game.Workspace.Lobby.ScriptedObjects.MasterCCDisplay.NextButton.NextGui.NextGuiB
local ClickN = NextButton.Click

function nextb()
    CurrentSetting.Value = CurrentSetting.Value + 1
    ClickN:Play()
    if CurrentSetting.Value == 4 then
        CurrentSetting.Value = 1
    end
end

NextButton.MouseButton1Click:Connect(nextb)

--Prev Button

local PrevButton = game.Workspace.Lobby.ScriptedObjects.MasterCCDisplay.PrevButton.PrevGui.PrevGuiB
local ClickP = PrevButton.Click

function prevb()
    ClickP:Play()
    CurrentSetting.Value = CurrentSetting.Value - 1
    if CurrentSetting.Value == 0 then
        CurrentSetting.Value = 3
    end
end

PrevButton.MouseButton1Click:Connect(prevb)
--Value Reader (Changer GUI)
local DisplayMain = game.Workspace.Lobby.ScriptedObjects.MasterCCDisplay.MainDisplay

function valuereadergui()
    if CurrentSetting.Value == 1 then -- Hair
        DisplayMain.HairSelectionMainframe.Enabled = true
	    DisplayMain.HairSelectionMainframe.AlwaysOnTop = true
	    DisplayMain.FaceSelectionMainframe.Enabled = false
	    DisplayMain.FaceSelectionMainframe.AlwaysOnTop = false
	    DisplayMain.SkinSelectionMainframe.Enabled = false
	    DisplayMain.SkinSelectionMainframe.AlwaysOnTop = false
    end
    if CurrentSetting.Value == 2 then -- Face
	    DisplayMain.HairSelectionMainframe.Enabled = false
	    DisplayMain.HairSelectionMainframe.AlwaysOnTop = false
	    DisplayMain.FaceSelectionMainframe.Enabled = true
	    DisplayMain.FaceSelectionMainframe.AlwaysOnTop = true
	    DisplayMain.SkinSelectionMainframe.Enabled = false
	    DisplayMain.SkinSelectionMainframe.AlwaysOnTop = false
    end
	if CurrentSetting.Value == 3 then -- Skin
	    DisplayMain.HairSelectionMainframe.Enabled = false
	    DisplayMain.HairSelectionMainframe.AlwaysOnTop = false
	    DisplayMain.FaceSelectionMainframe.Enabled = false
	    DisplayMain.FaceSelectionMainframe.AlwaysOnTop = false
	    DisplayMain.SkinSelectionMainframe.Enabled = true
	    DisplayMain.SkinSelectionMainframe.AlwaysOnTop = true
    end
end

CurrentSetting.Changed:Connect(valuereadergui)
1 Like

Would you please edit your post and show us your script.

Have you tried checking if there might be other frames blocking the Face ui? Have you tried using the ZIndex property?

The ZIndex property determines the order at which GuiObjects will render, the gui with the highest ZIndex is rendered first and is on top of all of the other this. You might want to set the ZIndexBehaviour property, or whatever it’s called, in your ScreenGuis to Global instead of Sibling

I dont know of the ZIndex property. Even so, wouldnt that just make them load one on top of the other or can it change the order of the GUIs in real time?

I dont have access to my script right now, but I’ll post it soon. Essentially what the script does is when you click on the arrows it adds or subtracts to a value and when you reach the end of the list (#4 or #0 depending on which arrow you click) it sets the value back to 1 or 3 depending on which arrow you click. Theres a separate script to detect which number it is, and the hair/face UIs correspond to the value. 1 is for hair and 2 is for face. It then goes into the SurfaceGui’s properties and sets enabled to true/false.

You can alter the ZIndex property in real time

1 Like

How does it work exactly? I read the wiki page but I’m not sure I understand how to implement it into my script. I updated the original post with my script.

Nevermind, I think I got it. Gonna try implementing ZIndex.

So if I set the ZIndex to 1 it will appear over a ZIndex 2?

No, works the other way around. The higher the ZIndex, the higher the layering precedence. This was explained and you could perform searches first too. Read up on ZIndex here.