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:

01--//Getting 4 Corners Of Car
02local TempCar = game.Workspace:WaitForChild("TempCar")
03local BR = TempCar.BR   --This is referencing to four corners Bottom Right, Bottom Left, Top Right, and Top left.
04local BL = TempCar.BL
05--local TL =
06--local TR =
07TempCar.Primary.BodyThrust.location = Vector3.new(0,2,0.4)
08 
09--//Raycasts
10 
11--BottomRightRay
12local bottomRightRay = Ray.new(BR.Position, BR.Position + BR.CFrame.lookVector)
13local hitBR, position = game.Workspace:FindPartOnRayWithWhitelist(bottomRightRay, (game.Workspace.Enviorment.Track))
14if hitBR then
15    -- Just some notes, I haven't finished the script yet because I decided to work on another part.
View all 26 lines...
0
Please help Longjohnnn 28 — 4y
0
can you post the script TheRealPotatoChips 793 — 4y
0
ye Longjohnnn 28 — 4y

Answer this question