Beginners Scripting Guide (BETA)
  • Getting Started
  • Basic Data Types
  • Variables
  • Basic global functions
  • Number Arithmetic & Compounds Assignment
  • If statement
  • Function
  • Table & Dictionary
  • Loops
  • Creating An Object
  • Understanding Client & Server
  • RemoteEvent
  • Unfinished & In-progress
    • Methods
    • RemoteFunction
    • Basic libraries
    • Basic Services
    • Basic of Vector3 and CFrame
    • Basic built-in events
Powered by GitBook
On this page
  • ARITHMETIC
  • COMPOUNDS ASSIGNMENT
  • HOW ARITHMETIC WORKS
  • BASIC USAGE

Number Arithmetic & Compounds Assignment

✏ Beginners Scripting Guide ✏

PreviousBasic global functionsNextIf statement

Last updated 11 months ago

In this section, we will be discussing number arithmetics. Number arithmetics can be used to create a math expression for your script. Here are the tables.

ARITHMETIC

Operator
Operation

/

Division

*

Multiplication

+

Addition

-

Subtraction

%

Modulus

^

Exponent

COMPOUNDS ASSIGNMENT

Operator
Operation

+=

Addition

-=

Subtraction

*=

Multiplication

/=

Division

%=

Modulus

^=

Exponentiation

HOW ARITHMETIC WORKS

Division - Division can be used to divide numbers. Multiplication - Multiplication can be used to multiply numbers. Addition - Addition can be used to add numbers. Subtraction - Subtraction can be used to subtract numbers. Modulus - Modulo can be used to find a reminder of a division. Exponent - Exponent takes two value called base and power.The base is mulitplied with itself for power times (ex: 5^2 = 5*5)

BASIC USAGE

This is how you should use arithmetic and compound assignments in a script.

DIVISION

local Number = 2
print(Number / 2) -- 1
Number = 4
Number /= 2
print(Number) -- 2

MULTIPLICATION

local Number = 2
print(Number * 2) -- 4
Number = 4
Number *= 2
print(Number) -- 8

ADDITION

local Number = 2
print(Number + 2) -- 4
Number = 4
Number += 2
print(Number) -- 6

SUBTRACTION

local Number = 2
print(Number - 2) -- 0
Number = 4
Number -= 2
print(Number) -- 2

MODULUS

local Number = 2
print(Number % 2) -- 0
Number = 4
Number %= 3
print(Number) -- 1

EXPONENT

local Number = 2
print(Number ^ 2) -- 4
Number = 4
Number ^= 3
print(Number) -- 48
https://create.roblox.com/docs/luau/operators#arithmetic
https://create.roblox.com/docs/luau/operators#compound-assignment