# How to half a number in studio?

Is there any math function or method anybody could share? Just a simple question, sorry if it’s an inconvenience.

1 Like

Just take the number or variable and divide by 2. Say the variable is X

y=x/2
variable = (X + 16)/2

``````local Number = x / 2

print(Number)
``````

1 Like

Just use the `/` : `num /= 2`

That’s not necessary, because all you need to do is divide the number. The print will return the answer. (He was asking how to half a number.)

You mean the divide sign isn’t necessary?

This is what I mean to use. It will divide the number, then print it.

1 Like

Oh okay, makes sense. Is there any method to do this with players?

``````local Players = game:GetService("Players");
local AmountPlayers = #Players:GetPlayers();
local HalfPlayers = math.floor(AmountPlayers / 2 + .5);
print(AmountPlayers, HalfPlayers);
``````

What do you mean by with players?

1 Like

Halfing a player count, like what is displayed above.

Just use `math.round()` to estimate the half amount in case you want to exclude any decimals (`.25`, `.5`, etc), otherwise you can just do `print(Num / 2)`

``````local function HalfNumber(Num)
print(math.round(Num / 2))
end

HalfNumber(384.2938473) -- Should output back as 192``````
2 Likes