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

How do I make this model rotate on the proper axis?

I'm trying to make this model rotate normally, as if a table top or something.

function rotateMod(mod,center,rotation)
	local parts ={}
	local function scan(parent)
		for _,obj in pairs(parent:GetChildren()) do
			if (obj:IsA("BasePart")) then
				table.insert(parts,obj)
			end
			scan(obj)
		end
	end
	scan(mod)
	for _,part in pairs(parts) do
		part.CFrame = (center*rotation*(center:inverse()*part.CFrame))	
	end
end
local mod = game.Workspace["Lamp Post"]
local step = 1
repeat wait()
	rotateMod(mod,mod:GetModelCFrame(),CFrame.Angles(0,math.rad(step),0))
until mod == nil

However, I have no idea how to do this. I've never really scripted before so I would have no clue where to start.

1 comment

0

Use SetPrimaryPartCFrame()

1 answer

Set the primary part, by clicking on the model in workspace and setting it in properties. What the primary part does is basically when it moves the entire model will move in relation to that part.

Now, you can move the entire model around just like you would move a part around using CFrame by using

model:SetPrimaryPartCFrame(cframe)

Using this, you can rotate your model using CFrame. Hope this helped!

1 comment

0

Would I replace the entire script with that one code? I'm still quite confused. I've tried putting this into a normal rotation script which I put into the primary part, but it still doesn't seem to be working.

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