So I tried making my future coming obby game tidier by using CollectionService so I won’t have to put a script on each object and I’m having a problem with making the spinners spin. I had no errors, here’s the code:
local CollectionService = game:GetService("CollectionService")
local TaggedParts = CollectionService:GetTagged("Spinner2")
for _, TaggedPart in pairs(TaggedParts) do
while true do
wait()
TaggedPart:SetPrimaryPartCFrame(TaggedPart.PrimaryPart.CFrame * CFrame.Angles(0, 0, TaggedPart.Speed.Value))
end
end
Any help is appreciated!
I added tags using a plugin, which worked for other objects, but not the spinners.
I’m not fully familiar with the Collection Service, however you could try:
local CollectionService = game:GetService("CollectionService")
local TaggedParts = CollectionService:GetTagged("Spinner2")
for _, TaggedPart in pairs(TaggedParts) do
while true do
wait()
TaggedPart:SetPrimaryPartCFrame(TaggedPart.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,0,TaggedPart.Speed.Value))
end
end
I’m not 100% sure on this but i have used the code to rotate objects before.
while true do
for _, TaggedPart in ipairs(TaggedParts) do
TaggedPart:SetPrimaryPartCFrame(TaggedPart.PrimaryPart.CFrame * CFrame.Angles(0, 0, TaggedPart.Speed.Value))
end
task.wait()
end
Problem is that the while loop prevents the next cycle of the for loop since its ran on a single thread, just switch it around like this and it will work