How do I make it so that the ray comes out of a bottom of a part?
Here’s my code (I’m fairly new to scripting rays)
local startP = script.Parent.Start.Position
local endP = script.Parent.End.Position
local rayOrigin = startP
local rayDirection = startP.CFrame * CFrame.Angles(math.rad(-90),0,0)
local ray = Ray.new(rayOrigin, rayDirection)
local Baseplate = workspace:FindPartOnRay(ray)
print(Baseplate) -- the ray should point towards the baseplate so the output should put out baseplate (right?)
Please let me know if there’s any way to go about this, thanks!
Theres a new method of raycasting, the one you’re using is deprecated. The code below should work.
local startP = script.Parent.Start.Position
local rayOrigin = startP
local rayDirection = (startP.Y - startP.Y) + -10
local ray = workspace:Raycast(rayOrigin, Vector3.new(0,rayDirection,0))
local Baseplate = ray
print(Baseplate) -- the ray should point towards the baseplate so the output should put out baseplate (right?)
First of all, Ray.new() is bad, use Workspace:Raycast()
Now that you know that, I would do it like this:
local startP = script.Parent.Start
local ray = game:GetService("Workspace"):Raycast(startP.Position, startP.CFrame.UpVector * CFrame.new(0, -100, 0))
local baseplate = ray.Instance
print(baseplate.Name)