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
01 | local HUD = Instance.new( "ScreenGui" ) |
02 | HUD.Parent = script.Parent |
04 | local Backframe = Instance.new( 'Frame' ) |
07 | Backframe.Position = UDim 2. new( 0 , 25 , 0 , 25 ) |
08 | Backframe.Size = UDim 2. new( 0 , game.Players.LocalPlayer.Character.Humanoid.MaxHealth / 5 , 0 , 25 ) |
10 | Backframe.BackgroundColor 3 = Color 3. new( 0.35 , 0.35 , 0.35 ) |
12 | local frame = Instance.new( "Frame" ) |
14 | frame.Position = UDim 2. new( 0 , 25 , 0 , 25 ) |
15 | frame.Size = UDim 2. new( 0 , game.Players.LocalPlayer.Character.Humanoid.Health / 5 , 0 , 25 ) |
18 | local textLabel = Instance.new( "TextLabel" ) |
20 | textLabel.Position = UDim 2. new( 0 , 25 , 0 , 25 ) |
21 | textLabel.Size = UDim 2. new( 0 , 25 , 0 , 25 ) |
22 | textLabel.BackgroundColor 3 = BrickColor.White().Color |
23 | textLabel.BackgroundTransparency = 1 |
24 | textLabel.Text = game.Players.LocalPlayer.Character.Humanoid.Health |
25 | textLabel.ZIndex = 3 -- |