Most of these terms can be answered through searching their related APIs, documentation or any articles on the Developer Hub. Feel free to perform a little research there. I could still answer your questions.
Magnitude
Magnitude is the distance between two vectors. It is a scalar quantity and it will never be negative. This is often good for cases when you want to compare how far apart two points are from each other. It is the property of a vector, so any vector will have a magnitude: in your case, you are dealing with Vector3 (a vector created on a 3D axis). To use it, you simply need to type .Magnitude on a vector.
local newVector = Vector3.new(0, 0, 0)
print(newVector.Magnitude)
In the case of a vector equation as mentioned in return’s post, subtracting two vectors gives you a vector as well. Therefore, when you perform a vector subtraction, you can also access the resultant vector’s magnitude.
local firstVector = Vector3.new(50, 50, 50)
local secondVector = Vector3.new(100, 100, 100)
local resultantVector = firstVector - secondVector
print(resultantVector.Magnitude)
Raycasting
Raycasting is the creation of a line segment from an origin to a target direction. Raycasts can be used for a large number of cases, though most often it is used to check whether a part intersects the created line segment (meaning the raycast passes through your target points). Ordinarily, a ray is comprised of three parts: the origin (where the ray begins) and the direction (where the ray points towards). Creating a ray is simple and done through the Ray.new constructor.
local originVector = Vector3.new(0, 0, 0)
local directionVector = Vector3.new(50, 50, 50)
local ray = Ray.new(originVector, directionVector)
Keep this in mind: larger rays are more expensive. Expensive means that it could have more impact on performance, which means lag for your game. Short rays have very small costs to perform and usually they won’t do anything to your game. You can use hundreds of them very quickly.
Using Raycast and Magnitude
There are cases where you’ll encounter the need to use a raycast or magnitude, not necessarily together though. In order to use raycasting, you will need to construct a ray (as mentioned above) and use one of the methods responsible for returning intersecting parts. A common example is FindPartOnRay: it is responsible for finding the first part that intersects a ray.
As for magnitude, again, it’s straight forward: use it for cases where you need to compare the distance between two points. Parts in the workspace have their positions represented by vectors, so you can use vector subtraction and access the magnitude to check how far apart positions are.
Note: You can use this to check a character’s distance from something as well, but you really shouldn’t. The engine offers a quick way to do this already, Player.DistanceFromCharacter. That way, new rig constructs won’t affect your calculations and you can have a simple way to check distances.
Incorporating Raycasting
This too is also explained pretty much with the segments above. In your case, with melee, you’ll probably be looking to construct a ray that starts at the tool’s handle, is directed a few studs out (you can use Handle.LookVector for this, which is a vector describing where the part is pointed in relative space to the part) and a length of 1-3.
DebrisService
Answered by reading the documentation for Debris. It allows you to queue the removal of an object after a given interval It’s essentially like calling wait and then Destroy on an instance. That’s it, really.