I made a custom Health Bar. I use the same code in the Roblox Wiki. It did work, but only on studio. Why?
local player = game.Players.LocalPlayer
local Frame = script.Parent
local ScreenGui = script.Parent
Frame.PlayerName.Text = player.Name
local healthBar = ScreenGui.HealthContainer.HealthBar
player.CharacterAdded:connect(function(character)
local humanoid = character:WaitForChild('Humanoid')
humanoid.HealthChanged:connect(function(health)
local healthPercentage = health / character.Humanoid.MaxHealth
healthBar.Size = UDim2.new(healthPercentage, 0, 1, 0)
end)
end)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

5 comments
Make sure this is in a LocalScript
It is in the local script
Is it in a localscript that is inside StarterPlayerScripts or StarterGui?
Its in StarterGui
Any errors? I would try waiting for the frame using waitforchild. Also why do you have two variables for the same thing? "Frame" is getting the parent of the script and so is "ScreenGui".