so me and my friend are making a game and i'm working on a health bar. and I dont know how to change the zindex of a gui specifically when your hp reaches a certain point. Thanks for looking at this post
You can do this with a local script:
local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local humanoid = char:FindFirstChild("Humanoid") or char:WaitForChild("Humanoid") local gui = THE PATH TO THE GUI YOU WANNA CHANGE THE ZINDEX OF local hp_required = THE CERTAIN HP TO TRIGGER THE CHANGE local zindex = THE ZINDEX YOU WANT TO CHANGE IT TO local default_zindex = THE DEFAULT ZINDEX humanoid:GetPropertyChangedSignal("Health"):Connect(function() if humanoid.Health <= hp_required then gui.Zindex = zindex else gui.Zindex = default_zindex end end)