Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

3 comments

0

But what if I wanted to use TweenSize instead of that

0

If you wanted to TweenSize, there would be a delay ree.

0

No way to not make it delay or least prevent it little bit?

This discussion is preserved as it was. New answers, comments, and votes are closed.