Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I detect what part of a ray hit something?

Asked by 4 years ago
Edited 4 years ago

Can you please give me an example on how to detect which part of a ray was hit? It's for a car that I'm making.

I'll only post part of the script, here is is:

--//Getting 4 Corners Of Car
local TempCar = game.Workspace:WaitForChild("TempCar")
local BR = TempCar.BR   --This is referencing to four corners Bottom Right, Bottom Left, Top Right, and Top left.
local BL = TempCar.BL
--local TL = 
--local TR = 
TempCar.Primary.BodyThrust.location = Vector3.new(0,2,0.4)

--//Raycasts

--BottomRightRay
local bottomRightRay = Ray.new(BR.Position, BR.Position + BR.CFrame.lookVector)
local hitBR, position = game.Workspace:FindPartOnRayWithWhitelist(bottomRightRay, (game.Workspace.Enviorment.Track))
if hitBR then
    -- Just some notes, I haven't finished the script yet because I decided to work on another part.
end

--BottomLeftRay
local bottomLeftRay = Ray.new(BL.Position + BR.Position + BR.CFrame.lookVector)
local hitBL, position = game.Workspace:FindPartOnRayWithWhitelist(bottomLeftRay, (game.Workspace.Enviorment.Track))
if hitBL then

end
--TopRightRay (These are just for sorting my stuff out)

--TopLeftRay
0
Please help Longjohnnn 28 — 4y
0
can you post the script TheRealPotatoChips 793 — 4y
0
ye Longjohnnn 28 — 4y

Answer this question