I don’t know if this is what is causing the problem but there is a huge memory leak here.
while wait() do
for i, v in pairs(folder:GetChildren()) do
if v:IsA("BasePart") then
v.CFrame = v.CFrame * CFrame.fromEulerAnglesXYZ(0.0,0.1,0.0)
v.Touched:Connect(function(hit) -- This is where it is (You are setting up a hit connection every time the code loops)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end
end
end
local TweenService = game.TweenService
TweenService:Create(v, TweenInfo.new(
1, -- Time to Complete
Enum.EasingStyle.Linear, -- Standard Linear
Enum.EasingDirection.InOut, -- In case if you want a Different Style, use this
-1 -- So it repeats forever
), {Orientation = Vector3.new(0,360,0)}):Play()
Should be more smoother
Edit: New Script
local TweenService = game.TweenService
local A = TweenService:Create(v, TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut
), {Orientation = v.Orientation + Vector3.new(0,360,0)})
A.Completed:Connect(function()
A:Play()
end)
A:Play()
Personally i would not do this due to the fact that tweens can strain performance and with 10+ spinners, it’s possible you could see the servers Fps dropping.
Do you really need to make v.Touched connections so much? It’s most likely server lag for the thousands of redundant connections eating up memory. You could follow a proposed solution of this reply and use runservice
local Run = game:GetService("RunService")
local folder = --the folder full of spinners
local SpinSpeed = 15 --15 degrees per second
for _, spinner in folder:GetChildren() do
spinner.Touched:Connect(function() --establish a connection for each spinner ONCE only
--do the hurting
end)
end
Run.Heartbeat:Connect(function(delta)
for _, spinner in folder:GetChildren() do
spinner.CFrame *= CFrame.Angles(0, math.rad(delta * SpinSpeed), 0)
end
end)