View difference between Paste ID: THep2pBC and KfyiKvQA
SHOW: | | - or go back to the newest paste.
1
local AudioID = 1271507422
2
3-
local HealthGUI_prototype = script:FindFirstChild("HealthGUI")
3+
4-
local lastHealth = 100
4+
5-
local lastHealth2 = 100
5+
6-
local maxWidth = 0.96
6+
7
shirt = Instance.new("Shirt", char)
8-
local humanoid = script.Parent.Humanoid
8+
9
pants = Instance.new("Pants", char)
10-
if (humanoid == nil) then
10+
11-
	print("ERROR: no humanoid found in 'HealthScript v3.1'")
11+
12
char.Pants.PantsTemplate = "rbxassetid://138139370"
13
end)
14
15-
function CreateGUI()
15+
16-
	local p = game.Players:GetPlayerFromCharacter(humanoid.Parent)
16+
17-
	HealthGUI_prototype.Parent = p.PlayerGui
17+
18
hair3.Size=Vector3.new(0.1,0.1,0.1)
19
hair3.Transparency=0
20-
function UpdateGUI(health)
20+
21-
	tray = HealthGUI_prototype.tray
21+
22-
	local width = (health / humanoid.MaxHealth) * maxWidth
22+
23-
	local height = 0.83
23+
24-
	local lastX = tray.bar.Position.X.Scale
24+
25-
	local x = 0.019 + (maxWidth - width)
25+
26-
	local y = 0.1
26+
27-
	
27+
28-
	tray.bar.Position = UDim2.new(x,0,y, 0) 
28+
29-
	tray.bar.Size = UDim2.new(width, 0, height, 0)
29+
30-
	-- If more than 1/4 health, bar = green.  Else, bar = red.
30+
31-
	if( (health / humanoid.MaxHealth) > 0.25 ) then
31+
32-
		tray.barRed.Size = UDim2.new(0, 0, 0, 0)
32+
33-
	else
33+
34-
		tray.barRed.Position = tray.bar.Position
34+
35-
		tray.barRed.Size = tray.bar.Size
35+
36-
		tray.bar.Size = UDim2.new(0, 0, 0, 0)
36+
37-
	end
37+
38-
	
38+
39-
	if ( (lastHealth - health) > (humanoid.MaxHealth / 10) ) then
39+
40-
		lastHealth = health
40+
41
end
42-
		if humanoid.Health ~= humanoid.MaxHealth then
42+
43-
			delay(0,function()
43+
44-
				AnimateHurtOverlay()
44+
45-
			end)
45+
46-
			delay(0,function()
46+
47-
				AnimateBars(x, y, lastX, height)
47+
48-
			end)
48+
49-
		end
49+
50-
	else
50+
51-
		lastHealth = health
51+
52-
	end
52+
53
game.Players.PlayerAdded:connect(function(plr)
54
    plr.CharacterAdded:connect(function(chr)
55
        chr:WaitForChild("Humanoid").Died:connect(function()
56-
function HealthChanged(health)
56+
            plr:LoadCharacterAppereance
57-
	UpdateGUI(health)
57+
        end)
58-
	if ( (lastHealth2 - health) > (humanoid.MaxHealth / 10) ) then
58+
    end)
59-
		lastHealth2 = health
59+
end)