part.Touched doesnt accept non player parts but accepts player parts

I have been trying to work on learning on how to print the name of the part touched but I dont know why my script only register player parts and not non player parts I have attached the script and the video please help me

local pert = workspace.Part


pert.Touched:Connect(function(otherPart)
	
	print(otherPart.Name)
	
end)

while true do
	task.wait(0.3)
	local os = pert.Size
	pert.Size = pert.Size + Vector3.new(0, 1, 0)
	local ns = pert.Size

	local Offsety = (ns.Y - os.Y) / 2
	pert.Position = pert.Position + Vector3.new(0, Offsety, 0)

	
end

1 Like

This event only fires as a result of physical movement, so it will not fire if the CFrame property was changed such that the part overlaps another part. This also means that at least one of the parts involved must not be Anchored at the time of the collision.

1 Like

Is there any way I could achieve the effect where the part I want touches the other part and it is unanchored?

Yes, but I would not use .Touched events for this, I’d make a custom function that suits your needs.

Code:

local part = workspace.Part
local alreadyTouched = {}

local function onTouched(otherPart)
	print(otherPart.Name)
end

while true do
	task.wait(0.3)

	local oldSize = part.Size

	part.Size += Vector3.new(0, 1, 0)

	local offsetY = (part.Size.Y - oldSize.Y) / 2
	part.Position += Vector3.new(0, offsetY, 0)

	local touchingParts = workspace:GetPartsInPart(part)

	for _, otherPart in touchingParts do
		if not alreadyTouched[otherPart] then
			alreadyTouched[otherPart] = true
			onTouched(otherPart)
		end
	end
end

As the red block grows upward once it begins overlapping the white part workspace:GetPartsInPart(part) will detect the white part and you can print its name. Nothing needs to be unanchored. GetPartsInPart() checks which parts currently share space with the red block.

Thanks for the help but I am also trying to make the touched part unanchored but I don’t know why the part starts to fly though the print name works now

local part = workspace.Part
local alreadyTouched = {}

local function onTouched(otherPart)
	print(otherPart.Name)
	otherPart.Anchored = false 
end

while true do
	task.wait(0.3)

	local oldSize = part.Size

	part.Size += Vector3.new(0, 1, 0)

	local offsetY = (part.Size.Y - oldSize.Y) / 2
	part.Position += Vector3.new(0, offsetY, 0)

	local touchingParts = workspace:GetPartsInPart(part)

	for _, otherPart in touchingParts do
		if not alreadyTouched[otherPart] then
			alreadyTouched[otherPart] = true
			onTouched(otherPart)
		end
	end
end
![Screen Recording 2026-07-12 221230 (1)|video](upload://vUhgUpIO5vinOtrThA7LwELC0DY.mp4)



You have accidentally put the video in the code format, so I can’t see the video.

The flying parts are because of physics, it’s normal engine behaviour.


my bad

Oh, that is not supposed to happen. It should not fly like that. Check the bounding boxes of both parts. Basically hitboxes.

1 Like

Thanks for the help its fixed now

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