This is for a on-screen health bar. Sometimes, when its auto-healing, it shows something like, 87.39293478289901283/99 health. Is there any way to stop that?
repeat wait() until game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() while wait() do local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") script.Parent.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0) script.Parent.Parent.Version.Text = Humanoid.Health.."/"..Humanoid.MaxHealth end
If there's anything I can do, please inform me. Thanks!
Hey, quite a simple fix. you can use math.floor, or math.ceil on the number in order to make it go to the specified whole value (math.floor will keep the current integer and math.ceil will make the number go to its next integer)
return math.floor(10.1) --> 10 return math.ceil(10.1) --> 11
Additionally, if you want to round the number to its closest value you can just use
math.floor(number + 0.5)
(thanks Aleph)
I had this question about a year ago when I was working on a project. What you need is to learn to format strings. https://developer.roblox.com/en-us/articles/Format-String
This is what you will probably be using.
("%u"):format("Decimal here")
I'm not well versed in string formatting but I think this is what you may use.