#model doesnt rotate properly

1 messages · Page 1 of 1 (latest)

barren wing
#

in m script my model only rotates the primarypart but nothing else

local TS = game:GetService("TweenService")
local m = workspace:WaitForChild("elf")

if not m.PrimaryPart then
    m.PrimaryPart = m:FindFirstChild("PrimaryPart")
end

local wp1 = script.Parent.Parent.wp1
local wp2 = wp1.Parent.wp2

if m.PrimaryPart then
    local tInfo = TweenInfo.new(7, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
    local p1 = wp1.Position
    local tweens1 = {}

    for _, p in pairs(m:GetDescendants()) do
        if p:IsA("MeshPart") then
            local cframe = p.CFrame
            local np1 = p1 + (p.Position - m.PrimaryPart.Position)
            local t1 = TS:Create(p, tInfo, {CFrame = CFrame.new(np1) * cframe.Rotation})
            table.insert(tweens1, t1)
        end
    end

    for _, t in pairs(tweens1) do
        t:Play()
    end

    task.wait(7)

    local rInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
    local rotGoal = CFrame.Angles(0, math.rad(-90), 0)
    local rotTweens = {}

    for _, p in pairs(m:GetDescendants()) do
        if p:IsA("MeshPart") then
            local rotT = TS:Create(p, rInfo, {CFrame = p.CFrame * rotGoal})
            table.insert(rotTweens, rotT)
        end
    end

    for _, rt in pairs(rotTweens) do
        rt:Play()
    end

    task.wait(0.5)

    local tweens2 = {}
    local p2 = wp2.Position

    for _, p in pairs(m:GetDescendants()) do
        if p:IsA("MeshPart") then
            local cframe = p.CFrame
            local np2 = p2 + (p.Position - m.PrimaryPart.Position)
            local t2 = TS:Create(p, tInfo, {CFrame = CFrame.new(np2) * cframe.Rotation})
            table.insert(tweens2, t2)
        end
    end

    for _, t in pairs(tweens2) do
        t:Play()
    end
end
ebon cave
#

if you are trying to rotate all the parts in a model. You can just rotate the primary part and other parts should be rotated with the primary part.

bitter blade
#

thats exactly what he's doing, that doesn't work

#

sorry to be blunt

#

for OP, you'll want to weld all your parts to the primarypart and THEN itll work

#

or, if you want to keep it all anchored it's a bit more difficult

#

but you can use :PivotTo() on the model and use a CFrameValue with a .Changed event to rotate the entire thing

#

welding is easiest imo

ebon cave
#

I am just trying to help.

bitter blade
#

im sorry bro that was mean

#

my bad og

ebon cave
#

np

barren wing
#

Sry for late answer but I welded everything but it still doesn’t work @bitter blade

bitter blade
#

things are unanchored now?

#

except primarypart?