How to ignore collision when teleporting a part?

Heya! I have this line of code:

model = script.Parent
model:MoveTo(Vector3.new(-146.16, 4.822, -163.825))

it works alright, but a part is in the way, and there will be more parts blocking its path soon. So how would I make it ignore all parts when doing this?
Thanks for answering <3

2 Likes

It’s as simple as this.
Make a collision group.

Don’t scripts use hitboxes tho?

The :MoveTo() function intentionally moves the model so it doesn’t collide with parts at the given destination. You should be using :SetPrimaryPartCFrame() instead. This function will move the model to the given CFrame without caring about if there’s parts in the way.

This means that you would use something like this instead:

model:SetPrimaryPartCFrame(CFrame.new(-146.16, 4.822, -163.825))

Edit:

As @caviarbro has mentioned, :SetPrimaryPart() will be deprecated in the future and superseded by :PivotTo() as mentioned in this announcement. In other words, in the long run you’re better off using something like this instead of the example I gave above:

model:PivotTo(CFrame.new(-146.16, 4.822, -163.825))

Using this function is also better because it shouldn’t cause floating point drift when repeatedly moving an object.

1 Like

You should actually use :PivotTo() because SetPrimaryCFrame is going to be deprecated and you don’t need PrimaryPart in order for this to work.

2 Likes