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

How to stop Tween Service from changing orientation?

Asked by 5 years ago

I have this code I found on the DevForms, however when I execute the code the model goes into a random orientation rather than a straight tween.

local function tweenModel(model, CF)
    local CFrameValue = Instance.new("CFrameValue")
script.Parent.Cash.PrimaryPart = MainPart
    CFrameValue.Value = model:GetPrimaryPartCFrame()

    CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
        model:SetPrimaryPartCFrame(CFrameValue.Value)
    end)

    local tween = tweenService:Create(CFrameValue, info, {Value = CF})
    tween:Play()

    tween.Completed:Connect(function()
        CFrameValue:Destroy()
    end)
end

I execute the function with this:

        tweenModel(MainPart.Parent, CFrame.new(script.Parent.Main_.Position))

This is what happens

How can I fix the problem so it evenly tweens out properly?

0
For this part (script.Parent.Main_.Position) make sure it's orientation is the same as the primary part's, also note, if you set the orientation in the script, it will act like setting position, and may put it on top of the register CPF2 406 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

CFrames also store orientation. If you only want to use the position, you use Vector3s, like this:

tweenModel(MainPart.Parent, Vector3.new(script.Parent.Main_.Position)
Ad

Answer this question