Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TW = game:GetService("TweenService")--Get Tween Service
- local Player = game:GetService("Players").LocalPlayer --Get The Player
- local Character = Player.Character or Player.CharacterAdded:Wait() --Wait For The Player Humanoid
- local Humanoid = Character:WaitForChild("Humanoid") --Get The Player Humanoid
- local Healthbar = script.Parent -- Get The Health Bar
- local function UpdateHealthbar() --Health Bar Size Change Function
- local health = math.clamp(Humanoid.Health / Humanoid.MaxHealth, 0, 1) --Maths
- local info = TweenInfo.new(Humanoid.Health / Humanoid.MaxHealth,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0) --Tween Info
- TW:Create(script.Parent,info,{Size = UDim2.fromScale(health, 1)}):Play() -- Create The Tween Then Play It
- end
- UpdateHealthbar()--Update The Health Bar
- Humanoid:GetPropertyChangedSignal("Health"):Connect(UpdateHealthbar) --Update The Health Bar When The Health Change
- Humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(UpdateHealthbar) --Update The Health Bar Wheb The MaxHealth Change
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement