Hello! So I’m planning on making an AirDrop system, but I was wondering, I will make airdrops, with RayPart, so, I will make them spawn randomly within a zone, and I will check if the ray.material is grass or concrete, but, I don’t remember how do I make a ray, I want a ray to go facing down like this:
How do I make a Ray goes straight down?
Another question, do you think I should tween the aidrop or add a BodyMover, or BodyVelocity to make it goes down?
Question, Do I need to use a loop, and how do I calculate distance, what will be origin? the start cframe ?and -cf CF would be the CFrame we want to go?
What is the loop for. If you are looking to fire it at certain times in your game use a bindable event. And the distance can be anything you want. Ten, twenty, one hundred, one thousand, whatever you want. Since UpVector is a direction, you negate it first because UpVector is the top direction, then you have a “DownVector” by negating it. Multiplying it by an arbitrary number distance will make it go distance studs from the cf. And cf is whatever CFrame.
Origin starts wherever you want. I don’t know how your game is structured so I can’t help you further about where. It might be a good idea for the origin to be cf.Position so you can get the position and down direction of the CFrame position where it should start
Try using find part on ray, make the ray’s origin the middle of it, the ray target Crate.Position - 1000 on y axis with vector3 and then tween it making the tween goals postion of the y axis being + .5 * total height above the find part on ray position.
local new_ray = Ray.new(script.Parent.Part.Position, -script.Parent.Part.CFrame.UpVector*workspace.Baseplate.Position)
local hit,position = workspace:FindPartOnRayWithIgnoreList(new_ray, {script.Parent["Metal Crate"], script.Parent.Part},false, false)
if hit then
print(hit.Name)
end
It’s not printing anything even when there’s a part down
local part = script.Parent
local new_ray = Ray.new(part.Position, -part.CFrame.UpVector*40)
local part, position = game:GetService("Workspace"):FindPartOnRay(new_ray)
print(part, position)
Output:
Baseplate 53, 0, -10
The baseplate was within 40 studs of the direction.
while wait() do
local new_ray = Ray.new(script.Parent.Part.Position, -script.Parent.Part.CFrame.UpVector*script.Parent["Metal Crate"].Size.Y/2)
local hit,position = workspace:FindPartOnRayWithIgnoreList(new_ray, {script.Parent["Metal Crate"], script.Parent.Part},false, false)
if hit then
print(hit.Name)
script.Parent["Metal Crate"].BodyVelocity:Destroy()
script.Parent["Metal Crate"].Anchored = true
break
end
end
Do you think it would lag if there’s like 5 airdrops?
What happened to the tweening part? It’s not going to move at all with that script, and it won’t lag with only 5 parts moving. Also you need to make it choose a random position in the sky before the ray is created, less than 1000 studs in the sky, or make the ray bigger.