Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I make it so that when Health changes rapidly it follows?

Asked by 5 years ago

So I made an HP changing script so for example if my health is at 100 green bar is full if its 1 you will see 1/100 of green But what if its rapidly changing like i get damaged once and then get damaged .1 seconds after it does not seem like it changes for me I know I have to use a loop like while true do I tried but it keeps going back and forth from the damaged hp to the non damaged HP

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Human = char:WaitForChild('Humanoid')
local healthframe = script.Parent
local Imagelabel = script.Parent.Parent.Parent.ImageLabel
local defaultColor = Imagelabel.ImageColor3
rs = game:GetService("RunService").RenderStepped





    Human.HealthChanged:Connect(function(Hp)
                healthframe:TweenSize(UDim2.new(Hp/Human.MaxHealth,0,1,0,'Linear',-99))






            end)

1 answer

Log in to vote
0
Answered by 5 years ago
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Human = char:WaitForChild('Humanoid')
local runService = game:GetService("RunService")
local healthFrame = script.Parent
runService.RenderStepped:Connect(function()
    healthFrame.Size = UDim2.new(Human.Health/Human.MaxHealth,0,1,0)
end)

It's probably because you're using TweenSize, but for instant change you want to bind the function to a renderstep and also just use .Size.

0
But what if I wanted to use TweenSize instead of that User#22788 5 — 5y
0
If you wanted to TweenSize, there would be a delay ree. EDmaster24 0 — 5y
0
No way to not make it delay or least prevent it little bit? User#22788 5 — 5y
Ad

Answer this question