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

Problems with ZIndex?

Asked by
drew1017 330 Moderation Voter
9 years ago
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?

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 -.-. ObscureEntity 294 — 9y
0
#sweetpea11fir Didn't work. drew1017 330 — 9y
0
Check to see if the ZIndex of the BackHUD is lower then the ZIndex of the HUD Prohibetur 70 — 9y
0
ScreenGui's dont have ZIndex, color, position etc properties like Frames. drew1017 330 — 9y
View all comments (4 more)
0
On line 25,why are you using BrickColor for a Color3 value? woodengop 1134 — 9y
0
Did that before i knew what a Color3 was and forgot to change it. I changed it and it still doesen't work. drew1017 330 — 9y
0
BrickColor only works on Bricks. woodengop 1134 — 9y
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. Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
8 years ago

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 --

Ad

Answer this question