Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

A few questions: Are the parts all in one model, and are they anchored or not?

0

they are anchored and all in 1 model

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.