Hi, so I am trying to make it so everytime it hits a new part it will print it, but currently it only prints the first part it hit then stops. I've tried converting it from if hitPart to while hitPart do, that didn't work. Please help, all advice is appreciated. Thank you!
local car = script.Parent.Car.Value local seat = car.DriveSeat local BSM = car.Body.BSM local rayOriginL = BSM.LBSM.Position local rayDirectionL = BSM.LBSM.CFrame.LookVector * 20 local ray = Ray.new(rayOriginL, rayDirectionL) local hitPart, hitPosition = workspace:FindPartOnRay(ray) if hitPart then print("Hit part: " .. hitPart:GetFullName()) else print("Did not hit part") end
This is pretty easy to do.
All you need is a while loop
.
This here should work:
local car = script.Parent.Car.Value local seat = car.DriveSeat local BSM = car.Body.BSM local rayOriginL = BSM.LBSM.Position local rayDirectionL = BSM.LBSM.CFrame.LookVector * 20 while wait() do local ray = Ray.new(rayOriginL, rayDirectionL) local hitPart, hitPosition = workspace:FindPartOnRay(ray) if hitPart then print("Hit part: " .. hitPart:GetFullName()) else print("Did not hit part") end end