Here I am again! This time, I have run into issues when trying the :GetTouchingParts() function.
What I am trying to do:
Check if any other vehicle is in a certain area
If not:
Spawn a vehicle at a place
However, to be able to check the amount of parts touching, using the function provided above, you need to have CanCollide activated (which is bad, as else the vehicles might get flung) or a TouchInterest (which doesn’t exist unless a Touching function exists, which doesn’t in my spawn code).
Is there any alternative to that function to check how many parts are touching, or do I have to create a small “Touching” function to create a TouchInterest?
While hacky, you could connect an ‘empty’ lambda function to each of the vehicle’s parts ‘Touched’ signal.
local Workspace = workspace
local Vehicle = Workspace.Vehicle --Example reference to a vehicle model.
for _, Descendant in ipairs(Vehicle:GetDescendants()) do
if not (Descendant:IsA("BasePart")) then continue end
Descendant.Touched:Connect(function() end)
end
The thing is, that will return 0 no matter how many parts are touching that certain part if the part’s CanCollide is false and the part doesn’t have TouchInterest.