TweenService places parts on the Y-Axis if blocked

Hello!

I’ve been trying to create some smooth parts using the TweenService but have ran into a slight issue. When a part is moved using TweenService and there is an object blocking it, it will attempt to get around it by going on top of the Y-Axis. I have noticed that if I set CanCollide to false on both doors, there is absolutely no problem in with regards to tweening.

But when CanCollide is set to true, the part will go all the way to the top of the Y-Axis on the roof.

I would much perfer that CanCollide is set to true to have a realistic door if players were to try and go through it. Is there any way around this or am I doomed to have unrealistic doors?

Thank you! :slight_smile:

tl;dr how do you make TweenService parts go through CanCollide parts

I had a similar problem a while back.

Are you changing the size of the object by any chance? Also, are you using CFrame or Position to shift it?

1 Like

I am not changing the size, I am simply moving the door with the .Position.

local doorPart = door.Interaction.MainDoor
local start = doorPart.CFrame
local finish = start * CFrame.new(5.5, 0, 0)
local tweenInfo = TweenInfo.new(1) 
local goal = {}
goal.Position = Vector3.new(finish.X, finish.Y, finish.Z)
local tween = tweenService:Create(doorPart, tweenInfo, goal)
doorPart.CanCollide = false
tween:Play()
tween.Completed:Connect(function() doorPart.CFrame = finish doorPart.CanCollide = true end)
local goal = {}
goal.CFrame = CFrame.new(finish.X, finish.Y, finish.Z)

this should fix it.

2 Likes

As soon as I read @ChipioIndustries’s post about CFrame, I just had an idea about that. Just tried it and this has happened!

It will be a minor error in the code somewhere, not too hard to fix, but it has fixed the collision. Thank you both!

1 Like

In that case, you might want:

goal.CFrame = finish
3 Likes

You’re a legend. Thanks! :slight_smile:

2 Likes