local tweenserv = game:GetService("TweenService")
game:GetService("GuiService"):SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
local character = game.Players.LocalPlayer.Character
local hum = character:WaitForChild("Humanoid")
local health = hum.Health
local maxhealth = hum.MaxHealth
local greenHB = script.Parent.Frame.HB_Green
local redHB = script.Parent.Frame.HB_Red
local function Update()
script.Parent.Frame.TextLabel = math.floor(health .. "%")
greenHB:TweenSize(UDim2.new(health / maxhealth, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15 , true)
end
hum.GetPropertyChangedSignal("Health"):Connect(Update)
``
It may be because you have used a period instead of a colon near hum.GetPropertyChangedSignal(). Change it to hum:GetPropertyChangedSignal("Health"):Connect(update)
game:GetService("GuiService"):SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
local character = game.Players.LocalPlayer.Character
local hum = character:WaitForChild("Humanoid")
local greenHB = script.Parent.Frame.HB_Green
local redHB = script.Parent.Frame.HB_Red
local function Update()
local health = hum.Health
local maxhealth = hum.MaxHealth
script.Parent.Frame.TextLabel = math.floor(health .. "%")
greenHB:TweenSize(UDim2.new(health / maxhealth, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15 , true)
end
hum:GetPropertyChangedSignal("Health"):Connect(Update)
local starterGui = game:GetService("StarterGui") --needs to be StarterGui
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() --wait for character if it doesn't already exist yet
local humanoid = character:WaitForChild("Humanoid")
local gui = script.Parent
local frame = gui:WaitForChild("Frame")
local textLabel = frame:WaitForChild("TextLabel")
local greenHB = frame:WaitForChild("HB_Green")
local function onHealthChanged(health)
textLabel.Text = math.floor(health).."%" --you need to change the text label's text property
--also concatenate after the number has been floored
greenHB:TweenSize(UDim2.new(health / humanoid.MaxHealth, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15 , true)
end
humanoid.HealthChanged:Connect(onHealthChanged) --HealthChanged passes the humanoid's new health as an argument to the connected function
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)