Added a set of property modifications regarding the surfaces not being smooth for your script... I noted them with comments
06 | game:GetService( "StarterGui" ):SetCoreGuiEnabled( "Health" , false ) |
09 | local Players = game:GetService( "Players" ) |
10 | local Player = Players.LocalPlayer |
14 | Character = Player.Character |
17 | local Human = Character:WaitForChild( "Humanoid" ) |
18 | coroutine.resume(coroutine.create( function () |
20 | if Character:findFirstChild( "Health" ) then |
21 | Character.Health.Disabled = true |
26 | local red = Instance.new( "Part" , Character) |
28 | red.FrontSurface = "Smooth" |
29 | red.BackSurface = "Smooth" |
30 | red.LeftSurface = "Smooth" |
31 | red.RightSurface = "Smooth" |
32 | red.BottomSurface = "Smooth" |
33 | red.TopSurface = "Smooth" |
35 | red.Material = "Plastic" |
36 | red.BrickColor = BrickColor.Red() |
37 | red.FormFactor = "Custom" |
38 | red.Size = Vector 3. new( 4 , 0.5 , 0.5 ) |
41 | local green = Instance.new( "Part" , Character) |
43 | green.FrontSurface = "Smooth" |
44 | green.BackSurface = "Smooth" |
45 | green.LeftSurface = "Smooth" |
46 | green.RightSurface = "Smooth" |
47 | green.BottomSurface = "Smooth" |
48 | green.TopSurface = "Smooth" |
50 | green.Material = "Plastic" |
51 | green.BrickColor = BrickColor.new( "Lime green" ) |
52 | green.FormFactor = "Custom" |
53 | green.Size = Vector 3. new( 1 , 0.5 , 0.5 ) |
55 | local gmesh = Instance.new( "BlockMesh" , green) |
56 | gmesh.Scale = Vector 3. new( 4 , 1.2 , 1.2 ) |
59 | game:GetService( "RunService" ).RenderStepped:connect( function () |
61 | local MH = Human.MaxHealth |
62 | local HP = Human.Health |
63 | if MH ~ = math.huge then |
65 | Human.Health = Human.Health + 0.05 |
67 | green.BrickColor = BrickColor.new( "Lime green" ) |
68 | gmesh.Scale = Vector 3. new(((HP/MH)* 4 )+ 0.05 , 1.05 , 1.05 ) |
69 | gmesh.Offset = Vector 3. new((HP/MH)* 2 , 0 , 0 ) |
70 | red.CFrame = Character.Head.CFrame * CFrame.new( 0 , 2 , 0 ) * CFrame.Angles(math.rad(angle), 0 , 0 ) |
71 | green.CFrame = red.CFrame * CFrame.new(- 2 , 0 , 0 ) |
73 | green.BrickColor = BrickColor.Yellow() |
74 | gmesh.Scale = Vector 3. new( 4.05 , 1.05 , 1.05 ) |
75 | gmesh.Offset = Vector 3. new( 2 , 0 , 0 ) |
76 | red.CFrame = Character.Head.CFrame * CFrame.new( 0 , 2 , 0 ) * CFrame.Angles(math.rad(angle), 0 , 0 ) |
77 | green.CFrame = red.CFrame * CFrame.new(- 2 , 0 , 0 ) |
This is one of the ways you can do this. Alternatively, you can have the bricks already made prior and simply clone them from a folder or lighting or w/e people store stuff in these days.
example:
1 | local red = game.ServerStorage.Folder.red:Clone() |
2 | local green = game.ServerStorage.Folder.green:Clone() |
of course, the folder isn't necessary but it'd look nicer.
I cant guarantee that the cloned variables won't bug out if you decide to mess with its CFrame and whatnot, but give it a shot if you find the first solution unappealing.