Hi everyone, so I am creating a sensor system on a bus that can detect humanoid or a part called ‘BusTouched’ which is placed at the rear in the body of all my buses, It has visual and audio alert system in placed too. When I first started, I did a simple script using Touched:Connect. It did work but I face issues such as when a tween service is on going nearby, it will disturb the Touched:Connect causing a looping of the warning sound until the tween service has stopped. So I decided to change the script and use raycast to detect the part named ‘BusTouched’. However I am now stuck, the script below. Line 7 is the problem, the “workspace.Parent.Parent.BusTouched”. I am not sure what to type in there to get all the bus model with the part ‘BusTouched’ to be whitelisted. The grouping of the A-chassis for the bus is below the script.
local sensor = script.Parent
local origin = sensor.Position
local direction = sensor.CFrame.LookVector * 88
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {workspace.Parent.Parent.BusTouched}
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
local raycastResult = workspace:Raycast(origin, direction, raycastParams)
if raycastResult then
script.Parent.Parent.Parent.Display.Screen.Collision:Play()
script.Parent.Parent.Parent.Display.Screen.SurfaceGui.RedHeadway.Visible = true
wait(0.25)
script.Parent.Parent.Parent.Display.Screen.SurfaceGui.RedHeadway.Visible = false
wait(0.25)
script.Parent.Parent.Parent.Display.Screen.SurfaceGui.RedHeadway.Visible = true
wait(0.25)
script.Parent.Parent.Parent.Display.Screen.SurfaceGui.RedHeadway.Visible = false
wait(0.25)
script.Parent.Parent.Parent.Display.Screen.SurfaceGui.RedHeadway.Visible = true
wait(0.1)
end

I’ve tried using :GetDecendents but I am not sure how I can put it in to the raycast script and make it work.