So I’m currently creating a game which you can engage in combat with bosses/players/npcs etc…
I created a gui which would record the Health/Experience/Energy
As shown. The Experience bar is unfinished and the Health bar works. Whilst I was testing the Energy bar I realised it wouldn’t change unless you reset. Their are no errors in the output. This is the scripting within it
local Players = game:GetService(“Players”)
local Workspace = game:GetService(“Workspace”)
local Player = Players.LocalPlayer
local Humanoid = Player.leaderstats2
local UI = Player.PlayerGui:WaitForChild(“Statistics”)
local Elements = UI:WaitForChild(“HUDPlayer”)
local MaxEnergy = Humanoid.Level.Value * 100
local Energy = Humanoid:WaitForChild(“Energy”).Value
local Stats = Elements
local Health = Stats:WaitForChild(“Energy”)
local MaxHealth = Stats:WaitForChild(“MaxEnergy”)
Health.Size = UDim2.new(0, MaxHealth.Size.X.Offset / MaxEnergy * Energy, 0, 25)
Humanoid.Energy.Changed:Connect(function()
Health.Size = UDim2.new(0, MaxHealth.Size.X.Offset / MaxEnergy * Energy, 0, 25)
end)
EDIT: The script is a local script.