math3d.vector3
value#Vector functions and constants. angle is in degrees.
local spot = math3d.vector3.new(0, 10, 0) + math3d.vector3.upUse it forposition, direction and velocity maths.
Vector functions and constants. angle is in degrees.
local spot = math3d.vector3.new(0, 10, 0) + math3d.vector3.upUse it forposition, direction and velocity maths.
Makes a vector from x, y and z numbers, where right, up and back are positive.
local spot = math3d.vector3.new(0, 10, 0)Use it forsetting where a part spawns, or the spot a player teleports to.
xRight is positive.yUp is positive.zBack is positive.Gives the vector 0, 0, 0, which points nowhere and has no length.
Use it forresetting a position, or starting a total that you add movements to.
Gives the vector that points straight up, which is the positive y direction.
Use it forlifting a spawned part above the ground, or launching players into the air from a jump pad.
Gives the length of a vector, which for a velocity is the speed.
local speed = math3d.vector3.magnitude(part.velocity)Use it forchecking how fast a car or ball is moving, using its velocity.
valueThe vector.Gives a vector that points the same way but has a length of 1.
local direction = math3d.vector3.normalize(player.position - door.position)Use it forfinding the direction from a cannon to a player, so you can push them that way.
valueThe vector; its length becomes 1.Gives the dot product of two vectors, a single number that shows how much they point the same way.
local rising = math3d.vector3.dot(part.velocity, math3d.vector3.up) > 0Use it forchecking whether a part is rising or falling, or whether something is facing a player.
aA vector.bAnother vector.Gives a vector at right angles to both of the vectors you pass in.
local side = math3d.vector3.cross(math3d.vector3.up, part.velocity)Use it forfinding the sideways direction of a moving car or player, like their left or right.
aA vector.bAnother vector.Gives the distance between two points, in studs.
local distance = math3d.vector3.distance(player.position, door.position)Use it foropening a door when a player gets close, or checking who is nearest to a goal.
aA point.bAnother point.Gives a point between two points, where alpha 0 is the start and 1 is the end.
local halfway = math3d.vector3.lerp(player.position, door.position, 0.5)Use it forplacing a marker halfway between two checkpoints, or moving something along a path step by step.
aThe start.bThe end.alpha0 gives a, 1 gives b, 0.5 the middle.Gives the angle between two vectors in degrees, so 0 means they point the same way.
local angle = math3d.vector3.angle(part.velocity, math3d.vector3.up)Use it forchecking whether a ramp is too steep to climb, or how far off target a shot is.
aA vector.bAnother vector.Turns a vector by a rotation in degrees, the same way an instance's rotation turns it.
local front = math3d.vector3.rotate(math3d.vector3.new(0, 0, -1), door.rotation)Use it forfinding which way a door or turret is facing, from its rotation.
valueThe vector to turn.rotationThe rotation in degrees.Color constructors. rgb rounds and clamps each channel to 0 to 255. hex takes "#RRGGBB" and needs the #.
door.color = math3d.color.hex("#FFAA00")Use it forpainting parts, lights and text in the colors you want, or blending one color into another.
Makes a color from red, green and blue amounts, each from 0 to 255.
door.color = math3d.color.rgb(255, 0, 0)Use it forturning a button red when it is pressed, and green again when it is ready.
rRed, 0 to 255.gGreen, 0 to 255.bBlue, 0 to 255.Makes a color from text like "#FFAA00", which must start with the #.
door.color = math3d.color.hex("#FFAA00")Use it forusing a color code you copied from a design tool or a palette website.
text"#RRGGBB", with the #.Makes a color from a hue in degrees, plus a saturation and value from 0 to 1.
door.color = math3d.color.hsv(120, 1, 1)Use it forcycling a disco floor through the rainbow by stepping the hue around the wheel.
hueDegrees, 0 to 360.saturation0 (grey) to 1.value0 (black) to 1.Blends two colors, where alpha 0 gives the first and 1 gives the second.
door.color = math3d.color.lerp(math3d.color.rgb(255, 0, 0), math3d.color.rgb(0, 0, 255), 0.5)Use it forfading a health bar from green to red as the player loses health.
aThe start.bThe end.alpha0 gives a, 1 gives b, 0.5 the middle.The rotation in degrees that turns the front (-Z) of an instance at from toward to.
door.rotation = math3d.look_at(door.position, player.position)Use it forturning a turret, camera prop or NPC statue so it faces a player or a point.
fromWhere the instance is.toThe point it should face.A random number from min up to max, max not included.
local speed = math3d.random(10, 20)Use it forpicking a random speed for a falling block, or a random wait before the next wave.
minThe lowest value.maxThe value it stays below.A random whole number from min to max, both included.
local roll = math3d.random_int(1, 6)Use it forrolling a dice, or picking a random map number from the ones you have.
minThe lowest whole number.maxThe highest whole number.Sets the seed of random and random_int for this script. The same seed gives the same numbers.
math3d.random_seed(42)Use it forgetting the same random obby layout every time, which helps while you are testing.
seedAny number.A new random generator of its own, for gacha, loot and shuffles that must be fair and replayable. The same whole-number seed gives the same draws on every server and release; without a seed it starts from the server's own randomness.
local rng = math3d.random_generator(42)Use it forloot drops or card shuffles that you can replay from a seed.
seedoptionalA whole number. The same seed gives the same draws everywhere; nil starts somewhere no one can predict.A generator that goes on exactly where the one whose state() gave this text was. Empty or other text is an error, so a player with no saved state yet starts with random_generator().
local rng = math3d.random_generator_from(profile:get("gacha.rng"))Use it forrestoring a generator from a saved state, for example after a player rejoins.
stateText from RandomGenerator:state(), such as "pcg32-v1:…".