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

CFraming rotations and position at the same time?

Asked by 6 years ago

This script builds a model by tweening, however, when I run it, the brick's rotations are fine, but the parts all go to position (0,0,0). How do I fix this? Am I doing something wrong? Here's the script:

wait (5)

for index, child in pairs(workspace.ItemF.Model:GetChildren()) do
    local TweenService = game:GetService("TweenService")
    local Part = child
    local Position = child.Position
    local info = TweenInfo.new(
        0.5,
        Enum.EasingStyle.Back,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )

    script.Parent.Value.Value = Vector3.new(Position.X,Position.Y+0.5,Position.Z)

    local Goals = 
    {
        Transparency = 0;
        CFrame = CFrame.fromEulerAnglesXYZ(Part.Orientation.X,Part.Orientation.Y,Part.Orientation.Z,  CFrame.new(script.Parent.Value.Value.X,script.Parent.Value.Value.Y,script.Parent.Value.Value.Z));
    }

    local Tween = TweenService:Create(Part,info,Goals)
    Tween:Play()
    wait (0.1)
end

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

This has to do with the way you are giving the CFrame. Try giving it like this on line 21

CFrame = CFrame.new(script.Parent.Value.Value.X,script.Parent.Value.Value.Y,script.Parent.Value.Value.Z)*CFrame.fromEulerAnglesXYZ(Part.Orientation.X,Part.Orientation.Y,Part.Orientation.Z)

What you did was give it the rotation then set the cframe after but it reset that rotation, this is the proper way of giving cframe with that type of rotation

0
It worked! Thanks! Reziztor 4 — 6y
Ad

Answer this question