Part Collision While Tween

I used to tween a part . when partA touches partB a function is to be done.
I use a print() to know the function is called or not . But no error or neither the function is called.
Is their is anyway to solve this

local partA = script .Parent

//Here I wrote the tweening code.  

partA.touched:connect(function(otherPart)
  if otherPart.Name == "partB" then
   print("Worked")
  end
end)

Does the parts has CanCollide property enabled?
is partB correctly named in workspace? no errors in output?
Could you show the entire code?

Test this one:

local TS = game:GetService("TweenService")

local partA = script.Parent
local goalCFrame = workspace:WaitForChild("partB").CFrame

partA.Touched:Connect(function(otherPart)
	if otherPart.Name == "partB" then
		print("Worked")
	end
end)

TS:Create(partA, TweenInfo.new(3), {CFrame = goalCFrame}):Play()
1 Like

Tweens (especially those on anchored parts) don’t respect physics so physics-based events (such as .Touched) won’t fire.

Try something like the spatial query method workspace:GetPartsInPart in a loop.

1 Like