ArePartsTouchingOthers
ArePartsTouchingOthers returns true if at least one of the given BasePart
are touching any other parts. Two parts are considered “touching” if they are within the distance threshold, overlapIgnored
.
If no parts are provided, false is returned.
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
A list of parts checks to see if any parts in the list are touching any parts not in the list |
||
0.000199999995
|
The part overlap threshold in studs that is ignored before parts are considered to be touching |
Returns
Return Type | Summary |
---|---|
True iff any of the |
Code Samples
Checking for Touching Parts
The code block below demonstrates how to use WorldRoot/ArePartsTouchingOthers
to check if parts in a list are touching any parts in the workspace not in the list.
First the script creates two square parts that overlap 1 stud, Part1
and Part2
. Then, it prints the value returned by ArePartsTouchingOthers() when Part1 is passed in partList
at three different overlap values: 0, 0.999, and 1. The first two times ArePartsTouchingOthers() is called return false
because the overlap values are less than the distance that Part1 and Part2 overlap. The third call returns true
because the overlap value is equal to the distance that the parts overlap.
-- Create 2 parts that overlap 1 stud local part1 = Instance.new("Part") part1.Name = "Part1" part1.Anchored = true part1.Parent = workspace part1.Transparency = 0.5 part1.Color = Color3.new(385, 100, 38) part1.Size = Vector3.new(2, 2, 2) part1.Position = Vector3.new(0, 4, 0) local part2 = Instance.new("Part") part2.Name = "Part2" part2.Anchored = true part2.Parent = workspace part2.Transparency = 0.5 part2.Color = Color3.new(200, 10, 0) part2.Size = Vector3.new(2, 2, 2) part2.Position = Vector3.new(0, 5, 0) local partList = { part1 } print(workspace:ArePartsTouchingOthers(partList, 0)) -- True print(workspace:ArePartsTouchingOthers(partList, 0.999)) -- True print(workspace:ArePartsTouchingOthers(partList, 1)) -- False