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

Rotating model script seperates parts over time??

Hello, I noticed that my rotating model script seperates my parts over time. It works but the pieces get seperated and I don't want that. How can I stop it from seperating?

-- Just put this script in a model to make it rotate
local speed = 25 -- the speed it spins at, change this to how fast you want it to spin

local orig = script.Parent
local rotation = 0
local cf = orig:GetModelCFrame()


function ModelCFrame(Model,Frame)
	local search,MidFrame,list = nil,Model:GetModelCFrame(),{}
	search=function(a)
		for n,o in pairs(a:GetChildren())do
			if(o:IsA("BasePart"))then
				table.insert(list,o)
			end
			search(o)
		end
	end
	search(Model)
	for n,o in pairs(list)do 
		o.CFrame=Frame*MidFrame:toObjectSpace(o.CFrame)
	end 
end


while(wait())do
	rotation = rotation+(speed/5)
	if(rotation>360)then rotation = 0 end
	ModelCFrame(orig,cf*CFrame.Angles(0,math.rad(rotation),0))
end



-- 1Topcop (WebGL3D/Java3D)

2 comments

0

SetPrimaryPartCFrame(), give the model a primary part then do SetPrimaryPartCFrame(model.CFrame * CFrame.Angles(0,math.rad(90),0))

0

???, how?

1 answer

✓ Accepted answer

In a model there is a PrimaryPart property, this determines the "Hinge" point or in other words, a point which checks where its rotating from, Set the PrimaryPart to any part in the model..

After that, apply this script

local model = model
while true do wait()
	model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(1),0))
end

this should rotate the whole model by 1 forever. Feel free to ask questions, mess with the 1, try 2 or 3, make it fast..

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