Not sure how to make a spinning model

I’m trying to create a spin effect like this, I have a box with galaxy decals, this is the result im trying to achieve: https://gyazo.com/00daea3b71aec74ea7cc03d1418e562c
This is what I get: https://gyazo.com/0cd9be8cd0f7b20ba616a768d777b325
I’m not sure how I would make it spin, but this is the code i’m using

wait(6)
local cam = game.Workspace.CurrentCamera
local map = game.ReplicatedStorage.RTZ
local user = game.Workspace:WaitForChild(game.ReplicatedStorage.User.Value)
local char = game.Players.LocalPlayer.Character 
user.Archivable = true
char.Archivable = true	
local cros = char:Clone()
local clone = user:Clone()


clone.PrimaryPart = clone.HumanoidRootPart
cros.PrimaryPart = cros.HumanoidRootPart
cros.HumanoidRootPart.Anchored = true
clone.HumanoidRootPart.Anchored = true
for a,b in pairs(cros:GetChildren()) do
	if b:IsA("Script") then
		b:Destroy()
	end
end
for a,b in pairs(clone:GetChildren()) do
	if b:IsA("Script") then
		b:Destroy()
	end
end
cros.Parent = game.Workspace
clone.Parent = game.Workspace
map.PrimaryPart = map:WaitForChild("ReturnParent")
map.PrimaryPart.Anchored = true
map:SetPrimaryPartCFrame(CFrame.new(0,5000,0))--char:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,50,0))
map.Parent = game.Workspace
wait(.2)
if map then
	for a,b in pairs(map:GetChildren()) do
		if b.Name == "Return1" then
			spawn(function()
				for i = 1, 900 do wait(0.1)
					b.Rotation = b.Rotation - Vector3.new(-1,0,0)
				end
			end)
			--b.Org.Transparency = 1
		end
	end
	for a,b in pairs(map:GetChildren()) do
		if b.Name == "Return3" then
			spawn(function()
				for i = 1, 900 do wait(0.1)
					b.Rotation = b.Rotation - Vector3.new(1,0,0)
				end
			end)
			--b.Org.Transparency = 1
		end
	end
	for a,b in pairs(map:GetChildren()) do
		if b.Name == "Return2" then
			spawn(function()
				for i = 1, 900 do wait(0.1)
					b.Rotation = b.Rotation - Vector3.new(1,0,0)
				end
			end)
			--b.Org.Transparency = 1
		end
	end
	for a,b in pairs(map:GetChildren()) do
		if b.Name == "ReturnParent" then
			spawn(function()
				for i = 1, 900 do wait(0.1)
					b.Rotation = b.Rotation - Vector3.new(1,0,0)
				end
			end)
			--b.Org.Transparency = 1
		end
	end
	for a,b in pairs(map:GetChildren()) do
		if b.Name == "Main" then
			local nc = clone:Clone()
			nc.PrimaryPart = nc.HumanoidRootPart
			nc.PrimaryPart.Anchored = true
			nc:SetPrimaryPartCFrame(b.Org.CFrame)
			nc.Parent = b 
			cam.CameraSubject = map.Part
			--b.Org.Transparency = 1
		end
	end
end

char.Humanoid.Died:connect(function()
	cam.CameraSubject = char.Humanoid
	map:Destroy()
	clone:Destroy()
	cros:Destroy()

	script:Destroy()	
end)

wait(10)
cam.CameraSubject = char.Humanoid
map:Destroy()
clone:Destroy()
cros:Destroy()
script:Destroy()

Rather than rotating each individual part, put them into a model and rotate the primary part using Model:SetPrimaryPartCFrame(cframe)

This will rotate the box rather than each part.

I used SetPrimaryPartCFrame to set the box’s CFrame and set the camerasubject from a part in the box’s model, but I don’t know how I would rotate with it

The simplest way would be to have a loop. While not exactly optimal it will work.

For example:

local box = game.ReplicatedStorage.RTZ
box.PrimaryPart = box:WaitForChild("ReturnParent")
box.PrimaryPart.Anchored = true
box:SetPrimaryPartCFrame(CFrame.new(0,5000,0))
box.Parent = workspace

wait(0.2)

for i = 1, 900 do
	box:SetPrimaryPartCFrame(box.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(1),0))
	wait()
end

Hope this helps!

1 Like

Thank you! Also, how would I freeze the camera?

You could set the cameras type to scriptable in a local script and then set it’s orientation manually. You could also just freeze the players control script. Never had to do this so not sure exactly what you mean.

If this helped make sure to mark it as a solution :smiley:

1 Like