I am new to scripting and I don't know how to use magnitude. Could someone help please? Thanks in advance!
You can use Magnitudes by adding '.Magnitude' at the end of Vector3 or Vector2 values
Magnitudes can be used when you want to find the length of a Vector3 or Vector2 value, like without the X,Y and Z values of a Vector3 value
For example:
Vector3.new(0,0,0).Magnitude
Magnitude is basically the Distance of the Vector from the 0, 0
or 0, 0, 0
(Origin) point.
It can be used if you want to know the Distance from one Object to another.
local Object1 = game.Workspace.ExampleObject1 local Object2 = game.Workspace.ExampleObject2 local Distance = (Object1.Position - Object2.Position).Magnitude print(Distance)
This works beause we subtract Object1's Position with Object2's position which gives you another vector that is pointing away from Object2 we then get the Magnitude of the result.
There are brackets around the subtraction because we want the magnitude of the result of the subtraction. Which tells lua