Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Teleported part not firing touched event?

Howdy. I have a part (call it part A) that is inside a doorway of sorts. Another script teleports a new part (call it part B) inside of part A.

Part A has the following script:

	function onTouch(part)
	wait()
	print("Touched")
	if part.Parent.Name == "Room" then
		print("Room")
		script.Parent.Parent.OpenEnds.Value = script.Parent.Parent.OpenEnds.Value - 1
		script.Parent:Destroy()
	end
	end
	script.Parent.Touched:connect(onTouch)

The code that teleports part B into part A:

	roomModel.Parent = game.Workspace
	--roomModel:MoveTo(position)
	roomModel:SetPrimaryPartCFrame(CFrame.new(position))
	if roomModel.PrimaryPart.Position.Y > script.Parent.Position.Y then
		roomModel:Destroy()
	end

The way part B is teleported is in a SetPrimaryPartCFrame. As a result, part B teleports inside part A. The problem I am having is that it seems that the onTouch function is not firing, as neither "Touched" nor "Room" print. Even though part B is CFramed into part A, part A's script does not register them as touching. Thanks in advance.

1 answer

✓ Accepted answer

I believe Touched doesn't run if it's directly tp'ed in the part , try using magnitude?

This discussion is preserved as it was. New answers, comments, and votes are closed.