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

My rotation script still isn't working smoothly pls help?

Asked by 6 years ago

guys finally r u all now happy i did it as best as i can script: how do i make it smoother without changing wait()?

local model = script.Parent
local mainPart = model.Center -- the "Origin" of rotation.

--Rotation values (in degrees):

local rotX = 5
local rotY = 0
local rotZ = 0

local delay = 0.9 -- delay between each "Frame"

local mTable = {}
local offsetTable = {}

function getListOfParts(inst)
    for i, v in pairs(inst:GetChildren()) do
        if v:isA("BasePart") then
            table.insert(mTable, v)
        else
            getListOfParts(v)
        end
    end
end

getListOfParts(model)

for i, v in pairs(mTable) do
    offsetTable[i] = mainPart.CFrame:toObjectSpace(mTable[i].CFrame) 
end

while wait(delay) do
    mainPart.CFrame = mainPart.CFrame * CFrame.Angles(math.rad(rotX), math.rad(rotY), math.rad(rotZ))
    for i, v in pairs(mTable) do
        v.CFrame = mainPart.CFrame * offsetTable[i]
    end
end

thx hope it was goos blah blah blah

0
A few questions: Are the parts all in one model, and are they anchored or not? UgOsMiLy 1074 — 6y
0
they are anchored and all in 1 model Theroofypidgeot 21 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

You can literally just move it 1 degree at a time. What you have to do here, though is to set the PrimaryPart of the model to the center.

I don't think that you can make it smoother if you are rotating it at 11 fps, so you would make it 30 fps.

This is all you'd need

local model = script.Parent

while wait() do
    model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0,math.rad(1),0))
end
Ad

Answer this question