Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My door parts are going on top of my door when I tween it? [closed]

Asked by 6 years ago

I have a door, and 2 union parts which are the sides that slide out when tweened, but when I try it they still tween to the right position, but just get pushed on top of the door. When I turned off "CanCollide" in all the parts and unions of the door it worked, but it seems it doesn't tween properly when CanCollide is on for everything. But when I have CanCollide off for everything I can walk through it which is an issue.

Gif of CanCollide on for everything (Broken version) https://gyazo.com/a619dcd02ff39a4ccee1003752e518ba

Gif of CanCollide off for everything (Working version)

https://gyazo.com/da21e27fe4783dde54a0658d28ac0a45

And here is the script I use to handle the tweening

local tweenService = game:GetService("TweenService")
local part = script.Parent.Parent.Parent.d1.Union
local part2 = script.Parent.Parent.Parent.d2.Union

local function onCard(hit)

    local tweeningInformation = TweenInfo.new(
        1,
        Enum.EasingStyle.Quint, 
        Enum.EasingDirection.In,
        0,   
        false, 
        0
    )

    local partProperties = {
    Position = Vector3.new(-17.311, 3.451, 32.719)
    }

    local partProperties2 = {
    Position = Vector3.new(-10.22, 3.302, 32.719)
}

    local Tween = tweenService:Create(part,tweeningInformation,partProperties)
    Tween:Play()
    local Tween = tweenService:Create(part2,tweeningInformation,partProperties2)
    Tween:Play()
end

script.Parent.Touched:Connect(onCard)

Locked by User#24403

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
3
Answered by 6 years ago

Basically, the problem here is that you are tweening with Position


BodyMovers


The position property of a part, like velocity and Orientation, factors in collisions. If the part is colliding with the hitbox of another object. However, BodyMovers such as BodyPositions, BodyGyros, Bodyforces , BodyVelocities can combat this.


CFrame


If you do not want to bodymovers and just want to tween it, use the CFrame property of the part. CFrame, unlike position does not factor in collisions. So it can do things you can't do with positions and going through walls. The transfer from Position to CFrame is actually pretty easy as you can directly inputting the position of the CFrame matrix without doing anything with the orientation like such : Cframe.new(vector3pos), with all that said, tweening the cframe can be done like such :

local ts = game:GetService("TweenService")
local tinfo = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local part = workspace.Part

local t = ts:Create(part,tinfo,{CFrame = CFrame.new(Vector3.new(-10.22, 3.302, 32.719))})
0
Thank you for the informative answer, it helped me a lot and the door works with much less code. Also I learned some stuff about moving parts! Superameno 34 — 6y
Ad