Attempt to call missing method 'GetPartsInPart'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A script fix that fixes weld with parts that arent touching the “welder” part.
  2. What is the issue? Include screenshots / videos if possible!
    I always get a Attempt to call missing method ‘GetPartsInPart’ error when running the game.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Changing arguments, yes.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
		if script.Parent:GetConnectedParts():GetPartsInPart()==nil then --Check if welded bricks arent touching and cleans
			w:Destroy() --Destroy weld if target is found: Welded, but not touching
		end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

This returns a table.

for _,v: BasePart in script.Parent:GetConnectedParts() do
	if #v:GetTouchingParts() >= 1 then
		return true
	end
end

2 Likes

It doesnt work, and now they fling themselves sometimes.

2 Likes

What are you trying to do exactly?

2 Likes

A game with an insert brick mechanic with a “Welder Part” that welds itself to other parts when touched.

2 Likes

maybe

for _, v: BasePart in script.Parent:GetConnectedParts() do
	if #workspace:GetPartsInPart(v) < 1 then
		w:Destroy()
        break
	end
end``` instead
2 Likes

Did not work. Heres the place file if you want to code the fix inside.
builders.rbxl (109.0 KB)

2 Likes

You want to do system that if some part already connected to weld, it won’t create new connection?

1 Like

GetPartsInPart is a method on Workspace, not parts, so that error is expected.

2 Likes

… No. Its a fix for a bug that causes welded parts that arent actually touching Part0, the weld is destroyed.

1 Like

i dont think it would work

but try this

also @MAXPROFI333 there is a error in the code I think

for _, v: BasePart in script.Parent:GetConnectedParts() do
local partsinside = workspace:GetPartsInPart(v)
if #partsInside == 0 then
        w:Destroy()
        break
    end
1 Like

Got an error. Workspace.WeldPart.Weld:18: Expected identifier when parsing expression, got ‘)’
Listen, the code you made is full of typos like the error and line 3 of the code.

1 Like
for _, v: BasePart in script.Parent:GetConnectedParts() do
local partsInside = workspace:GetPartsInPart(v)
if #partsInside == 0 then
        w:Destroy()
        break
    end

i made a typo

1 Like

The same error appears,

script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or hit.Name=="3x3x3 Ball" or hit.Name=="2x2x2" or hit.Name=="4x1x2" then
		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		local w=Instance.new("WeldConstraint")
		w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
		w.Parent=script.Parent
		for _, v: BasePart in script.Parent:GetConnectedParts() do
			local partsInside = workspace:GetPartsInPart(v)
			if #partsInside == 0 then
				w:Destroy()
				break
			end
	end
end)

At line 18.

1 Like
script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or hit.Name=="3x3x3 Ball" or hit.Name=="2x2x2" or hit.Name=="4x1x2" then
		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		local w=Instance.new("WeldConstraint")
		w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
		w.Parent=script.Parent
		for _, v: BasePart in script.Parent:GetConnectedParts() do
			local partsInside = workspace:GetPartsInPart(v)
			if #partsInside == 0 then
				w:Destroy()
				break
			end
                   end
	end
end)

I forgot to add the end

1 Like

Didnt fix it, there are still parts not touching that are welded.

1 Like

I don’t really know how but try:

script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or hit.Name=="3x3x3 Ball" or hit.Name=="2x2x2" or hit.Name=="4x1x2" then
		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		local w=Instance.new("WeldConstraint")
		w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
		w.Parent=script.Parent
		for _, v: BasePart in script.Parent:GetConnectedParts() do
			local partsInside = workspace:GetPartsInPart(v)
			if #partsInside > 0 then
				w:Destroy()
				break
			end
                   end
	end
end)
1 Like
script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or hit.Name=="3x3x3 Ball" or hit.Name=="2x2x2" or hit.Name=="4x1x2" then
		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		local w=Instance.new("WeldConstraint")
		w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
		w.Parent=script.Parent
		for _, v: BasePart in script.Parent:GetConnectedParts() do
			local partsInside = workspace:GetPartsInPart(v)
			if #partsInside >= 0 then
				w:Destroy()
				break
			end
                   end
	end
end)

or you can use this for >= 0

1 Like

It works but they sometimes break the laws of gravity and only fall a bit when i move on them.

1 Like
script.Parent.Touched:Connect(function(hit)
	if hit.Name=="2x1x2" or hit.Name=="3x3x3 Ball" or hit.Name=="2x2x2" or hit.Name=="4x1x2" then
		if hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		local w=Instance.new("WeldConstraint")
		w.Enabled=true
		w.Part0=script.Parent
		w.Part1=hit
		w.Parent=script.Parent
                script.Parent.Anchored = true
		hit.Anchored = true
		for _, v: BasePart in script.Parent:GetConnectedParts() do
			local partsInside = workspace:GetPartsInPart(v)
			if #partsInside >= 0 then
				w:Destroy()
				break
			end
                   end
	end
end)

try

1 Like