Despawning Vehicles On a SpawnPad

Context: When a player has access to spawn cars, you tend to run into people who may wish to block up the spawn pads for cars. This causes disruption in the flow of the game, and the task of the spawn pad. I have attempted to use SpawnPad:GetTouchingParts() and checking if the descendant is a car, but there was no luck.

Question: How can I achieve deleting cars on top of the spawn pad when someone wishes to spawn a car?

Code Example
if PassVariable then
    for _, V in pairs(SpawnPad:GetTouchingParts()) do 
        if V:IsDescendantOf(CarFolder) then 
            PromptDestruction(V["Parent"])
        end
    end
end

Any and all answers are appreciated!

1 Like

Raycast downwards above the vehicle spawn area.

local Workspace = workspace
local VehicleSpawn = Workspace.VehicleSpawn --Vehicle spawn location.

local Vehicles = { --Array of vehicle names.
	"Vehicle1",
	"Vehicle2",
	"Vehicle3"
}

local Direction = ((VehicleSpawn.Position - Vector3.new(0, 1, 0)) - VehicleSpawn.Position) --Get the direction of the raycast.
local Result = Workspace:Raycast(VehicleSpawn.Position + Vector3.new(0, 10, 0), Direction * 100) --Perform the raycast 10 studs above the vehicle spawn.
if Result then
	local Vehicle = Result.Instance:FindFirstAncestorOfClass("Model") --Attempt to find a 'Model' instance inside of the hierarchy of the hit instance.
	if Vehicle then
		if table.find(Vehicles, Vehicle.Name) then --If the name of the 'Model' instance exists within the array it must be a vehicle.
			Vehicle:Destroy() --Destroy the vehicle.
		end
	end
end