Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm getting this malformed number error. How do I fix that?

Asked by 6 years ago

What is in the title..

local health = player.Character.Humanoid.Health
script.Parent.Size = UDim2.new(0.health*3.63,0,2.3,0) 

Offset wasn't doing very well so I changed the values to scale. But when I try to add a 0.health it gives me the error saying: Malformed number How do I fix that?

Thanks!

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Hmm, you're getting the error because you used 0.health which is not a real number.

Try this:

local health = player.Character.Humanoid.Health
local maxHealth = player.Character.Humanoid.MaxHealth
script.Parent.Size = UDim2.new((health / maxHealth)*3.63,0,2.3,0) 
0
BOI GingeyLol 338 — 6y
0
You could also do (health / 100) * 3.63. Hope this helps. iishadowflames 41 — 6y
0
Or, tonumber('0.'..health)*3.63 hiimgoodpack 2009 — 6y
0
Just edited it, assuming you're trying to set the size of the gui object to the percentage of what the player's health is. iishadowflames 41 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

UDim2.new(0.health*3.63,0,2.3,0) is wrong. You better use UDim2.new(health/(10 ^ tonumber(#tostring(health)))*3.63, 0, 2.3, 0)

0
health is a number value though, so why the # operator? iishadowflames 41 — 6y
0
You can't use # on a number. hiimgoodpack 2009 — 6y
0
alright imma edit this SuperAndresZ_YT 202 — 6y

Answer this question