GetTouchingParts() issue

			local part = game.Workspace.Provinces[script.selectedProvinceVal.Value.Name]
			local border_lands = 0
			for i, v in(part:GetTouchingParts()) do
				if(v.Parent.Name == "SeaPartsF") then
					print("province is bordering a sea part")
				else
					if(v.province_owner.Value == game.ReplicatedStorage.Values.FactionFolder.FactionInfo.NationName.Value) then
						border_lands = border_lands + 1
					end
				end
			end

so this here is the code, the only issue is, all the stuff it touches are meshes and all of the rest are unions, is there a way to use GetTouchingParts for meshes/unions?

GetTouchingParts() works with unions and meshes. I dont understand what the problem is? Did you make sure that the parts are actually touching?

Unless he’s using SpecialMeshes which don’t actually change the collision model, and used the wrong CollisionFidelity for the Unions

hold on ill go quickly check

(gotta make up for the 30 limit

they do touch but it still doesnt work

can collide is on, can touch is on and its being done in a server script

the meshes are childs to a folder tho

Are your all your parts anchored? Correct me if i’m wrong but I think “touching” is handled by physics. Both parts cannot be anchored to find anything “touching”. Here’s a video of what I mean:


At least ONE item has to be controlled by physics and not anchored.

It may be because you aren’t getting the touching parts of a part, but rather a string. Correct me if I’m wrong:

local part = game.Workspace.Provinces[script.selectedProvinceVal.Value.Name] 
--- ^ Name is a string
part:GetTouchingParts()
-- ^ part is still a string

EDIT: its a list index, my mistake

2 Likes

the variable is a part, it isnt the name, in the brackets is the .Name property (its a object value

I haven’t used :GetTouchingParts much but when I did it seemed inconsistent.

If you never get a fix for your problem with :GetTouchingParts, I would recommend the usage of Spatial Query as an alternative method.

I already edited the post to say that I was wrong, read the full thing before you reply please.

GetTouchingParts should work with any BasePart (Part, MeshPart, Union, etc). Can you send a snip of your explore window?

I’m confused what the issue is. It seems like it’s working how it’s supposed to. Can you expand on your issue a bit more? A video of the problem also might help.

You should use GetPartsInPart() instead of GetTouchingParts(). GetTouchingParts() seems to rely on Roblox’s physics, just like the Touched event.

With GetPartsInPart you can whitelist/blacklist any part you’d like using RaycastParams.
Did you check if the parts that are supposed to be detected by GetTouchingParts() have CanCollide on? It checks if there’s any part physically touching another part, unlike GetPartsInPart checks for geometry and doesn’t care about CanCollide.

5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.