The op did not provide any information of him making an IntValue, so the best solution here is using Humanoid.Health
They didnât provide the information that they wanted to display the humanoids health either.
What âHealthâ other than a characterâs health was he wanting to display when he clearly referred to a LocalPlayer? Also this argument is beside the point. Cya
Just a value inside of the LocalPlayer from the opâs perspective it looked that way. So I was just trying to provide him with a fixed version to see if it would solve his problem. But I guess thatâs not the right thing to do? Adios though
What do you think I am doing? I spend a solid 30 min looking at my scripts and online before I make a post. Then after I make a post I use the knowledge you give me for future scripts and edit those scripts because I usually donât like how they work and I make them faster or function in a different way.
Still does not work this might 100% be impossible. Maybe health is not a number? Maybe a %? Or something?
On a totally unrelated note, Iâve seen a lot of developers adding semi-colons ( ; ) after some lines of code, could you explain why people are doing this? Is it for cosmetic purposes?
Not on Luau put for Python and stuff you kind of have to use them.
its a habit they inherit from programming in other language
Ohh, I see. Thereâs no performance boosts by using them?
no. 30 ssssssssssssssssssssssssss, also i remember reading somewhere roblox dont recommend putting semicolons at the end of variables
No
In Python instead of
if blah blah blah then
Blah Blah
Itâs
if blah blah blah;
blah blah
But thats only one example.
I see. Thank you for taking the time to reply!
Haha, it isnât necessary at all! I have been coding in Java since 2019 so I just have a habbit of adding ;
at the end of each lines of my code!
Side note: If you donât add semi-colons at the end of the lines of your code in java, it will give you syntax errors, so I have this as a habbit. Many other languages also have these kind of syntax rules.
In python they use :
colons for functions, conditions, loops etc.
a = 10
if a == 10:
print("its 10 :sunglasses:")
Ok it works.
But maybe too welll
How would I round it?
Yep thatâs why I said and other things.
Python and Luau is the only languages that I know rn.
Back onto the topic (thanks everyone for my inquiry regarding adding semi-colons), I made a health bar a few months ago, this seemed to work for me.
LocalScript
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.HealthChanged:Connect(function()
TextLabel.Text = math.round(Humanoid.Health)
end)
Edit: Added math.round()
Thanks, wetcoder!
You can use math.round(). That would round it off to the nearest integer.
Thank you
What I never knew the function math (or whatever it was) was in this language
MIND BLOWN
Now let me spend hours researching it lol.
Bye @jaipack17 thanks for the code
And thanks @Ayphic and @jaipack17 and @iam13robloxexactly for the semi-colon thing.
Bye You Guys!