Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ZIndex is broken?

Asked by 8 years ago

I have a TeamSelect GUI and an Intro GUI, but for some reason, the TeamSelect GUI (ZIndex 9) always appears over the top of the Intro GUI (ZIndex 10). Why is this happening?


Intro GUI: http://puu.sh/jdnGO/10fcaa93fe.png

function added(player)
    local NameOfGame = "Roblox Prison" -- For future-proofing

    local GUI = script.IntroGUI:clone()
    GUI.Parent = player:WaitForChild("PlayerGui")

    local ThisFrame = GUI.Frame
    local Text = ThisFrame.TextLabel
    local ClassicLoad = ThisFrame.ClassicLoadFrame
    local LoadText = ClassicLoad.LoadText

    Text.Visible = false -- Prepare for it to fade in

    repeat wait() until player.Character

    Text.TextTransparency = 1
    Text.Text = NameOfGame
    Text.Visible = true
    wait(5)
    while Text.TextTransparency > 0 do
        Text.TextTransparency = Text.TextTransparency - .05 -- Fade it in
        wait(.05)
    end
    wait(5)
    ThisFrame.Visible = false
end
game.Players.PlayerAdded:connect(added)

TeamSelect GUI: http://puu.sh/jdnJR/1e8f5eceaf.png

local player = game.Players.LocalPlayer -- assign a variable to the local player
frame = script.Parent.Frame
GuardButtonShake = 0
InmateButtonShake = 0
CivilianButtonShake = 0

local function getTeamPlayers(teamColor)
local output = {}
for _, v in pairs(game.Players:getPlayers()) do
if (not v.Neutral) and v.TeamColor == BrickColor.new(teamColor) then
table.insert(output, player)
end
end
return output
end

local function GuardJoin()
    if (#getTeamPlayers("Bright blue")) < 15 then
        if player.Neutral then
            player.Neutral = false
        end
        player.TeamColor = BrickColor.new("Bright blue")
        frame.Visible = false
    else
        if GuardButtonShake == 0 then
            frame.GuardJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.3)
            frame.GuardJoin.BackgroundColor3 = Color3.new(12, 66, 0)
            wait (0.2)
            frame.GuardJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.1)
            frame.GuardJoin.BackgroundColor3 = Color3.new(12, 66, 0)
        end
    end
end

local function InmateJoin()
    if (#getTeamPlayers("Medium stone gray")) < 25 then
        if player.Neutral then
            player.Neutral = false
        end
        player.TeamColor = BrickColor.new("Medium stone gray")
        frame.Visible = false
    else
        if InmateButtonShake == 0 then
            frame.InmateJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.3)
            frame.InmateJoin.BackgroundColor3 = Color3.new(12, 66, 0)
            wait (0.2)
            frame.InmateJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.1)
            frame.InmateJoin.BackgroundColor3 = Color3.new(12, 66, 0)
        end
    end
end

local function CivilianJoin()
    if (#getTeamPlayers("Bright orange")) < 10 then
        if player.Neutral then
            player.Neutral = false
        end
        player.TeamColor = BrickColor.new("Bright orange")
        frame.Visible = false
    else
        if CivilianButtonShake == 0 then
            frame.CivilianJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.3)
            frame.CivilianJoin.BackgroundColor3 = Color3.new(12, 66, 0)
            wait (0.2)
            frame.CivilianJoin.BackgroundColor3 = Color3.new(170, 0, 0)
            wait (0.1)
            frame.CivilianJoin.BackgroundColor3 = Color3.new(12, 66, 0)
        end
    end
end

frame.GuardJoin.MouseButton1Click:connect(GuardJoin)
frame.InmateJoin.MouseButton1Click:connect(InmateJoin)
frame.CivilianJoin.MouseButton1Click:connect(CivilianJoin)

Answer this question