Attempt to call missing method 'GetPartsInPart'

Welding doesn’t work if both parts are anchored

1 Like

Maybe you should try changing some physical properties. It doesn’t look like some script problem

1 Like

Just Touched event calls when part in the air

1 Like

None are anchored. Also, it didnt work.

1 Like

i dont really know how to fix but its really hard to fix this issue, but I think ill try:
I added alignposition hopefully it will work if it doesn’t work message me

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
local alignPos = Instance.new("AlignPosition")
		alignPos.MaxForce = 10000
		alignPos.MaxVelocity = 100
		alignPos.Responsiveness = 50
		alignPos.Parent = script.Parent

		alignPos.Attachment0 = script.Parent:FindFirstChild("Attachment") or Instance.new("Attachment", script.Parent)
		alignPos.Attachment1 = hit:FindFirstChild("Attachment") or Instance.new("Attachment", hit)
		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

This didnt even work and theyre now just flinging around when touching a brick.

1 Like

I think you should just listen to Jack. the error: Attempt to call missing method "GetPartsInPart
literally means that “script.Parent:GetConnectedParts():GetPartsInPart()” is a missing method, which means it doesn’t exist.

just use the function with workspace instead

1 Like

Got an error. GetConnectedParts is not a valid member of Workspace “Workspace”

1 Like

you might have misunderstood. all you have to do is do something like this:

workspace:GetPartsInParts() -- returns a table
1 Like

Argument 1 missing or nil
Error above.
Heres the script right now:

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
		if workspace:GetPartsInPart()==nil then --Check if welded bricks arent touching and cleans
			w:Destroy() --Destroy weld if target is found: Welded, but not touching
		end
	end
end)
1 Like

I think you should practice doing a bit of research on your own. you need to define a part of where the function should look for. in simple terms, the code does not know which part to see if there is another part inside it. here’s what you should do:

local overlapParams = OverlapParams.new()
-- configure your params here. example: overlapParams.FilterType

local partTable = workspace:GetPartsInParts(part, overlapParams)

overlapParams are a way to configure and limit the parts that you get in the table.
“Argument 1 missing or nil” implies that the first argument in :GetPartsInPairs() is missing, i.e. the part that the script should look into. hope this helps!

Whats the part variable for? Its never mentioned.

the first argument in the function

workspace:GetPartsInParts()

will be the part that the function will look into. if you have part1 as an instance in workspace and use the function, you need to have part1 as the first argument. doing that will cause the function too look for other parts that are inside part1

for example:

local part1 = Instance.new("Part", workspace)

local parts = workspace:GetPartsInPart(part1)
print(parts) -- would print a table with all parts inside part1. if there are no parts, then it would print out "{}"

I will update more errors tomorrow, i have to go sleep.

I am back, and this did not work.