New to lua, mainly use ruby. In ruby, if i wanted to print a value, say, health, I could do
hp = 100
print "HP: #{hp} /100
and it would output "HP: 100/100"
How does this translate into lua? None of the results I found on google worked in studio.
New to lua, mainly use ruby. In ruby, if i wanted to print a value, say, health, I could do
hp = 100
print "HP: #{hp} /100
and it would output "HP: 100/100"
How does this translate into lua? None of the results I found on google worked in studio.
Hey, as far as I know numbers get automatically turned into strings when printed, I am not a 100% sure it is this way (let me know if it works) but I am pretty confident this is how you do it. Let's say you wanted to print the health of a humanoid.
Health = Humanoid.Health
print(Health)
now, if that doesn't work (it should), then you must explicitely tell the script to turn the numbers into a string, and you do that with the tostring function.
Health = Humanoid.Health
print(tostring(Health))
If it works please remember to accept the answer and upvote, thanks you and good luck :)
You can print numbers. You can print pretty much any value.
You can convert anything to a string using 'tostring(value)'. If it does not work, it should return 'nil'.
try
print(hp/100)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
print(hp .. "/100")