I have an overhead hp bar for an rpg and you can clearly see that there is studs on the hp bar. how would i make this property "smooth" instead of "studs" by adding some lines of script?
print 'Hello world!' --Created by XanthicDragon --Inspired by "Sword Art Online: Burst" game:GetService("StarterGui"):SetCoreGuiEnabled("Health", false) local Players = game:GetService("Players") local Player = Players.LocalPlayer local Character repeat wait() Character = Player.Character until Character local Human = Character:WaitForChild("Humanoid") coroutine.resume(coroutine.create(function () while wait() do if Character:findFirstChild("Health") then Character.Health.Disabled = true end end end)) local red = Instance.new("Part", Character) red.Material = "Plastic" red.BrickColor = BrickColor.Red() red.FormFactor = "Custom" red.Size = Vector3.new(4, 0.5, 0.5) red.Anchored = true local green = Instance.new("Part", Character) green.Material = "Plastic" green.BrickColor = BrickColor.new("Lime green") green.FormFactor = "Custom" green.Size = Vector3.new(1, 0.5, 0.5) green.Anchored = true local gmesh = Instance.new("BlockMesh", green) gmesh.Scale = Vector3.new(4, 1.2, 1.2) local angle = 0 game:GetService("RunService").RenderStepped:connect(function () angle = angle + 3 local MH = Human.MaxHealth local HP = Human.Health if MH ~= math.huge then if HP < MH then Human.Health = Human.Health + 0.05 end green.BrickColor = BrickColor.new("Lime green") gmesh.Scale = Vector3.new(((HP/MH)*4)+0.05, 1.05, 1.05) gmesh.Offset = Vector3.new((HP/MH)*2, 0, 0) red.CFrame = Character.Head.CFrame * CFrame.new(0, 2, 0) * CFrame.Angles(math.rad(angle), 0, 0) green.CFrame = red.CFrame * CFrame.new(-2, 0, 0) else green.BrickColor = BrickColor.Yellow() gmesh.Scale = Vector3.new(4.05, 1.05, 1.05) gmesh.Offset = Vector3.new(2, 0, 0) red.CFrame = Character.Head.CFrame * CFrame.new(0, 2, 0) * CFrame.Angles(math.rad(angle), 0, 0) green.CFrame = red.CFrame * CFrame.new(-2, 0, 0) end end)
Added a set of property modifications regarding the surfaces not being smooth for your script... I noted them with comments
print 'Hello world!' --Created by XanthicDragon --Inspired by "Sword Art Online: Burst" game:GetService("StarterGui"):SetCoreGuiEnabled("Health", false) local Players = game:GetService("Players") local Player = Players.LocalPlayer local Character repeat wait() Character = Player.Character until Character local Human = Character:WaitForChild("Humanoid") coroutine.resume(coroutine.create(function () while wait() do if Character:findFirstChild("Health") then Character.Health.Disabled = true end end end)) local red = Instance.new("Part", Character) red.FrontSurface = "Smooth" --these here red.BackSurface = "Smooth" red.LeftSurface = "Smooth" red.RightSurface = "Smooth" red.BottomSurface = "Smooth" red.TopSurface = "Smooth" red.Material = "Plastic" red.BrickColor = BrickColor.Red() red.FormFactor = "Custom" red.Size = Vector3.new(4, 0.5, 0.5) red.Anchored = true local green = Instance.new("Part", Character) green.FrontSurface = "Smooth" --and these too green.BackSurface = "Smooth" green.LeftSurface = "Smooth" green.RightSurface = "Smooth" green.BottomSurface = "Smooth" green.TopSurface = "Smooth" green.Material = "Plastic" green.BrickColor = BrickColor.new("Lime green") green.FormFactor = "Custom" green.Size = Vector3.new(1, 0.5, 0.5) green.Anchored = true local gmesh = Instance.new("BlockMesh", green) gmesh.Scale = Vector3.new(4, 1.2, 1.2) local angle = 0 game:GetService("RunService").RenderStepped:connect(function () angle = angle + 3 local MH = Human.MaxHealth local HP = Human.Health if MH ~= math.huge then if HP < MH then Human.Health = Human.Health + 0.05 end green.BrickColor = BrickColor.new("Lime green") gmesh.Scale = Vector3.new(((HP/MH)*4)+0.05, 1.05, 1.05) gmesh.Offset = Vector3.new((HP/MH)*2, 0, 0) red.CFrame = Character.Head.CFrame * CFrame.new(0, 2, 0) * CFrame.Angles(math.rad(angle), 0, 0) green.CFrame = red.CFrame * CFrame.new(-2, 0, 0) else green.BrickColor = BrickColor.Yellow() gmesh.Scale = Vector3.new(4.05, 1.05, 1.05) gmesh.Offset = Vector3.new(2, 0, 0) red.CFrame = Character.Head.CFrame * CFrame.new(0, 2, 0) * CFrame.Angles(math.rad(angle), 0, 0) green.CFrame = red.CFrame * CFrame.new(-2, 0, 0) end end)
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:
local red = game.ServerStorage.Folder.red:Clone() 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.
You can set the surface type of a part by using something like the following.
part.TopSurface = Enum.SurfaceType.Smooth -- but, you can also declare it as a string. part.TopSurface = "Smooth" -- or use the Enum value part.TopSurface = 0
The surface property names for all BasePart classes are TopSurface
, BottomSurface
,LeftSurface
, RightSurface
, BackSurface
, and FrontSurface
. BasePart BasePart is the base class for physical parts such as Part, WedgePart, MeshPart, and more.
Enum.SurfaceType reference: http://wiki.roblox.com/index.php?title=API:Enum/SurfaceType
BasePart reference: http://wiki.roblox.com/index.php?title=API:Class/BasePart