I have a script below that I am using as a reference. I am wondering how I can make a Ray between two parts I have in Workspace. The parts are named "Part" and "Part1".
Reference -
local Ray = Ray.new(game.Workspace.vislbIe.HumanoidRootPart.Position, game.Workspace.vislbIe.HumanoidRootPart.Position - Vector3.new(0,3,0)) local part = game.Workspace:FindPartOnRay(Ray,game.Workspace.vislbIe) --[[ (I am not wanting to create the Ray using the same method as this script, I simply wanted to see how this stuff works) ]]--
Now, I want to make a Ray begin on Part, then end at Part1. Here is a script from Roblox Wiki, this script is how I want to make my ray, minus the Tool handle.
local ray = Ray.new( Weapon.Handle.CFrame.p, -- origin (mouse.Hit.p - Weapon.Handle.CFrame.p).unit * 500 -- direction ) local ignore = game.Players.LocalPlayer.Character local hit, position, normal = Workspace:FindPartOnRay(ray, ignore)
Any solutions?
http://prntscr.com/ntni5s
Screenshot of parts above.
Ray.new has 2 arguments, 1st one is the starting position of the ray, the second the vector of the ray including length.
in your script
local startPos = Part.Position local rayVector = Part1.Position - Part.Position
then,
local ray = Ray.new(startPos, rayVector)