I have a problem, I don’t know why in my game, on public servers with people, rotation scripts are very slow or laggy. When on private servers and Studio, it looks faster.
I know that the problem is not with the script, as I use the same script in several games of mine in which it works perfectly. I thought it was a virus but I haven’t detected any with plugins.
I’m sorry if this is not the correct category, I don’t know which one it is.
yeah! heres
function rotateMod(mod,center,rotation)
local parts ={}
local function scan(parent)
for _,obj in pairs(parent:GetChildren()) do
if (obj:IsA(“BasePart”)) then
table.insert(parts,obj)
end
scan(obj)
end
end
scan(mod)
for _,part in pairs(parts) do
part.CFrame = (centerrotation(center:inverse()*part.CFrame))
end
end
local mod = script.Parent
local step = 1
for i = 0,360,step do
while true do
rotateMod(mod,mod:GetModelCFrame(),CFrame.Angles(0,math.rad(step),0))
wait()
end
wait()
end
I believe this is a lag issue. Avoid nesting :GetChildren and rather use :GetDescendants.
function rotateMod(mod,center,rotation)
local parts ={}
local function scan(parent)
for _,obj in pairs(parent:GetDescendents()) do
if (obj:IsA(“BasePart”)) then
table.insert(parts,obj)
end
end
end
scan(mod)
for _,part in pairs(parts) do
part.CFrame = (centerrotation(center:inverse()*part.CFrame))
end
end
local mod = script.Parent
local step = 1
for i = 0,360,step do
while true do
rotateMod(mod,mod:GetModelCFrame(),CFrame.Angles(0,math.rad(step),0))
wait()
end
wait()
end