Using CollectionService to spin multiple parts

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have a problem with CollectionService when I’m trying to spin multiple parts
  2. What is the issue? Include screenshots / videos if possible!

    I’ve tagged all of them, but only one works

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Here’ the script

local CS = game:GetService("CollectionService")
local spinbrick = CS:GetTagged("SpinBrick")

for _, part in pairs(spinbrick) do
	local partspeed = 0.05 
	
	while task.wait() do

		part.CFrame = part.CFrame * CFrame.Angles(0,partspeed,0) 

	end
	
end
1 Like

Try this:

local function Spin(Brick)
	local partspeed = 0.05 
	while task.wait() do
		Brick.CFrame = Brick.CFrame * CFrame.Angles(0, partspeed, 0) 
	end
end

for _, part in pairs(spinbrick) do
	Spin(spinbrick)
end

Also, it might be because the while loop is yielding the script.

he needs to create new thread since while wait() loops are endless
like this

local function Spin(Brick)
	local partspeed = 0.05 
	while task.wait() do
		part.CFrame = part.CFrame * CFrame.Angles(0, partspeed, 0) 
	end
end

for _, part in pairs(spinbrick) do
	task.spawn(Spin, part )
end
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.