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)
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.