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

The Health gui i made looks strange, help?

I was making a health gui, and i thought i was finished with it but, there was a couple problems when i tested it. One, when ever i move the Gui seems to "Leak" out and does this:

https://gyazo.com/3c022dea7e131bdf80b492e7ced04e7c

When it's susspose to look like this:

https://gyazo.com/f5afc06f1bd2b8d392c2d4afd4217509

I was thinking it was something to due to with the script which is:

--\\Player Variables
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character or Player.Character.Parent
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Health = Humanoid.Health
local MaxHealth = Humanoid.MaxHealth

--\\Change Frame When Humanoid Changes Health
Humanoid.Changed:connect(function(Health)
	if Health then
		local hp = Humanoid.Health/Humanoid.MaxHealth
		script.Parent:TweenSize(UDim2.new(hp, 0, 1, 0))
		wait()
	end
end)

Was it the way i put the Tween Size values or something else?

1 answer

✓ Accepted answer

Here is one of the problems, .Changed returns the property that changed, here, you are using it as Health and you are checking if it exists, by the way there is a special event for humanoids called .HealthChanged.

Another issue is, that this isn't how you use :TweenSize().

You should be using it like this

bool TweenSize (
    UDim2 endSize,
    EasingDirection easingDirection,
    EasingStyle easingStyle,
    float time,
    bool override = false,
    function(TweenStatus) callback = nil
)

Just do all of those up to override, where override HAS TO BE SET TO TRUE!

--\\Player Variables
local Player = game.Players.LocalPlayer
Player.CharacterAdded:wait()
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")

--\\Change Frame When Humanoid Changes Health
Humanoid.HealthChanged:connect(function()
	local hp = Humanoid.Health/Humanoid.MaxHealth
	script.Parent:TweenSize(UDim2.new(hp, 0, 1, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.5,true)
end)

1 comment

0

By the way, if Humanoid.Health is going over Humanoid.MaxHealth somehow, that might be why.

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