Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problems with ZIndex?

local HUD = Instance.new("ScreenGui")
HUD.Parent = script.Parent

local BackHUD = Instance.new('ScreenGui')
BackHUD.Parent = script.Parent

local Backframe = Instance.new('Frame')
wait(1) -- this isn't the problem if you're wondering
Backframe.Parent = BackHUD
Backframe.Position = UDim2.new(0, 25, 0, 25)
Backframe.Size = UDim2.new(0, game.Players.LocalPlayer.Character.Humanoid.MaxHealth / 5, 0, 25)
Backframe.ZIndex = 1 -- 
Backframe.BackgroundColor3 = Color3.new(0.35, 0.35, 0.35)
 
local frame = Instance.new("Frame")
frame.Parent = HUD
frame.Position = UDim2.new(0, 25, 0, 25)
frame.Size = UDim2.new(0, game.Players.LocalPlayer.Character.Humanoid.Health / 5, 0, 25)
frame.ZIndex = 2 --

local textLabel = Instance.new("TextLabel")
textLabel.Parent = HUD
textLabel.Position = UDim2.new(0, 25, 0, 25)
textLabel.Size = UDim2.new(0, 25, 0, 25)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.BackgroundTransparency = 1
textLabel.Text = game.Players.LocalPlayer.Character.Humanoid.Health
textLabel.ZIndex = 3 --

As you can see each of these frames have a ZIndex which should make it show in order of the text, frame (grey) and backframe (dark grey), but Backframe covers the others anyway. Any ideas?

8 comments

0

Maybe try changing ALL the ZIndex's at the very end of the script. I don't know. I'd at least try that. Sometimes roblox does stupid things with instances -.-.

0

#sweetpea11fir Didn't work.

0

Check to see if the ZIndex of the BackHUD is lower then the ZIndex of the HUD

0

ScreenGui's dont have ZIndex, color, position etc properties like Frames.

0

On line 25,why are you using BrickColor for a Color3 value?

0

Did that before i knew what a Color3 was and forgot to change it. I changed it and it still doesen't work.

0

BrickColor only works on Bricks.

0

But they have a property, Color, that returns their Color3. That part of his code is fine. Idk about the ZIndex thing. Sometimes if your arrange the guis in the order you want them (in the explorer), they will over-lap each other correctly, so I would try that.

1 answer

✓ Accepted answer

Your problem is that, they are not in the same screengui, so it isn't doing the ZIndex

Try putting them in the same gui

local HUD = Instance.new("ScreenGui")
HUD.Parent = script.Parent

local Backframe = Instance.new('Frame')
wait(1) -- this isn't the problem if you're wondering
Backframe.Parent = HUD
Backframe.Position = UDim2.new(0, 25, 0, 25)
Backframe.Size = UDim2.new(0, game.Players.LocalPlayer.Character.Humanoid.MaxHealth / 5, 0, 25)
Backframe.ZIndex = 1 -- 
Backframe.BackgroundColor3 = Color3.new(0.35, 0.35, 0.35)

local frame = Instance.new("Frame")
frame.Parent = HUD
frame.Position = UDim2.new(0, 25, 0, 25)
frame.Size = UDim2.new(0, game.Players.LocalPlayer.Character.Humanoid.Health / 5, 0, 25)
frame.ZIndex = 2 --

local textLabel = Instance.new("TextLabel")
textLabel.Parent = HUD
textLabel.Position = UDim2.new(0, 25, 0, 25)
textLabel.Size = UDim2.new(0, 25, 0, 25)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.BackgroundTransparency = 1
textLabel.Text = game.Players.LocalPlayer.Character.Humanoid.Health
textLabel.ZIndex = 3 --

This discussion is preserved as it was. New answers, comments, and votes are closed.