I searched every where but can’t find a tutorial on how to spin parts locally. It would be really nice if somebody could give me hand. (I am not to good at scripting)
Question:
Could this be done using the collection service or some different thing I don’t know of?
local CollectionService = game:GetService("CollectionService")
local p = CollectionService:GetTagged("SpiningParts")
for _, p in pairs(p)do
while true do
p.Orientation = p.Orientation +10
end
end
local runService = game:GetService('RunService')
local folderToSpin = workspace.SpinFolder --replace with your folder
local spinAmount = Vector3.new(0, 15, 0) --how many degrees to spin per second
runService.Heartbeat:Connect(function(step)
for i,v in pairs(folderToSpin:GetChildren()) do
v.Orientation += spinAmount*step --Replace X with your preferred axis.
v.AssemblyAngularVelocity = spinAmount*step
end
end)
local CollectionService = game:GetService("CollectionService")
local p = CollectionService:GetTagged("SpiningParts")
for _, p in pairs(p)do
while true do
script.Parent.Orientation += Vector3.new(0, 1, 0)
wait()
end
end
Your key word is “locally,” meaning you will use a LocalScript. As mentioned above, you can use collection service to get all of the instances, then do the same thing on the client as you would the server.
local CollectionService = game:GetService("CollectionService")
local PartCollection = CollectionService:GetTagged("SpiningParts")
local Stepped = game:GetService("RunService").Stepped
while Stepped:Wait() do
for _, part in ipairs(PartCollection) do
if part:IsA("BasePart") then
part.Orientation += Vector3.new(0, 1, 0)
end
end
end
This should fix the previously provided code from @NeonTaco135
I also just generally recommend using stepped in place of “wait()” due to reliability and stability. (RunService has many great events, some new ones are coming… eventually… wish they didn’t deprecate before the events were even usable…)