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

Limit Custom Heath Range?

I have a custom health bar I don't want it to take up all the space to make room for an image If you could help me optimize my code that would be great

local startergui = game:GetService('StarterGui')
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
local LocalPlayer = game.Players.LocalPlayer
local LocalChar = LocalPlayer.Character
local LocalHumanoid = LocalChar:WaitForChild("Humanoid")
LocalHumanoid:GetPropertyChangedSignal("Health"):connect(function()
local redzone = LocalHumanoid.MaxHealth / 4
if LocalHumanoid.Health <= redzone then
	
end
if LocalHumanoid.Health > redzone then
	
end
script.Parent.Size = UDim2.new(LocalHumanoid.Health / LocalHumanoid.MaxHealth,0,script.Parent.Size.Y.Scale,0)
end)

2 answers

I think the problem lies here with your line 14:

script.Parent.Size = UDim2.new(LocalHumanoid.Health / LocalHumanoid.MaxHealth,0,script.Parent.Size.Y.Scale,0)

This part:

script.Parent.Size.Y.Scale

may be causing your custom health bar to take up all of the space.

How to fix: You can instead "hard-code" (Manually choose) a number like 0.5 or something.

1 comment

0

It moves on the X not the Y

I just duplicated the frame made it transparent and added the original frame back and scaled it properly it works now

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