I’m trying to convert a percentage into fraction. I know how to do that, but I don’t know how can I achieve it with a script.
local function FracToPerc(n: number)
return (tonumber(n) or 0)/100
end
local function PercToFrac(n: number)
return (tonumber(n) or 0) * 100
end
It’s as simple as just reversing the operation to convert a fraction into a percentage.
local function PercToFrac(n: number)
return (tonumber(n) or 0) * 100
end
PercToFrac(20) -- 2000
It returns me this
That’s because 20 isn’t a percentage, 0.2 is.
If you’re going to use 20 as a value, use FracToPerc.