Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a script that checks if a value is a multiple of 10?

I'm awful with the maths engine, and I'm trying to make it so every time it reaches a multiple of 10, it increases the value for my inflation script I literally need it, I'm not going to show all of it because its not necessary but heres the maths part:

local module = require(game.ServerScriptService:WaitForChild("Prices_Module"))
val = 1 --what im changing
game.ReplicatedStorage.MarketStuff.prices.inflation.OnServerEvent:Connect(function(p,value,item,raise)

	print (item)
	print (value)
if raise == true then
val = val+1
if  val == 10 or 20 or 30 or 40 or 50 or 60 or 70 or 80 or 90 or 100 or 110 or 120 or 130 or 140 or 150 or 160 or 170 or 180 or 190 or 200 then --seriously? 
value = value*1.01
local n = math.floor(value *100)/100

Alternatively I could make it reset every time it reaches 10 but that feels clunky, id really prefer if it could check every time it reaches a multiple of 10

(This is a large scale game btw, so thats why I need the values to be so high)

Thanks :)

2 answers

✓ Accepted answer

You can check if a number is a multiple of 10 by using %

local n = 15

if (n % 10) == 0 then
	print("multiple of 10")
else
	print('not a multiple of 10')
end

% returns the remainder of a division, and if it returns anything other than 0 it means it's not a multiple of 10.

1 comment

1

cheers

you could do something like this:

if value % 10 == 0 then
	-- do stuff here
end

It basically checks if the value is even when divided by 10.

This discussion is preserved as it was. New answers, comments, and votes are closed.