This is the current layout of my script:
The script does not function, as a question I posted before somebody said local and non-local scripts do not function inside the camera. Right.
So I have multiple 'hitsensors' in this car (which is inside currentcamera), how can I listen to all of them at the same time and wait until one is touched?
First of all, since you are dealing with local parts, this has to be done inside of a local script to work.
What you are literally asking for is how to connect multiple events to the same function, which as is simple as it sounds:
local deb = false function HitDetected(partHit) if not deb then deb = true else return end print("Object hit from " .. partHit:GetFullName()) wait(5) deb = false end for _, v in ipairs(Parts) do if v.Name == "HitSensors" then v.Touched:connect(HitDetected) end end
Place this script within a model containing all the parts you want to connect to. With this script, you're able to get BOTH the part that was touched, and the part that touched it.
function partTouched(touchee, toucher) --touchee is the part that was touched --toucher is the part that touched the touchee end local parts = script.Parent:GetChildren() for i = 1, #parts do if parts[i]:IsA("BasePart") then parts[i].Touched:connect(function(toucher) partTouched(parts[i],toucher) end) end end