Hey, everyone I’m using for i,v and there’s just too much lag.
Here’s the code:
RunService.Stepped:Connect(function()
print("running")
-- Checks How Many Plates Are There, Then Rename it
for i, plates in pairs(PlatesFolder:GetChildren()) do
plates.Name = tostring(i)
-- Checks stepping plates
for i, stepPlates in pairs(SteppingPlatesFolder:GetChildren()) do
stepPlates.Name = tostring(i)
for i, spawns in pairs(SpawnsFolder:GetChildren()) do
spawns.Name = tostring(i)
end
end
end
end)
Why is this in a Stepped
event? It’s going to do the loop every frame
I need it to keep running everytime
Can’t you make it run every second instead? Also why do you need this to run every frame exactly?
while true do
wait(1)
for i, plates in pairs(PlatesFolder:GetChildren()) do
plates.Name = tostring(i)
end
-- Checks stepping plates
for i, stepPlates in pairs(SteppingPlatesFolder:GetChildren()) do
stepPlates.Name = tostring(i)
end
for i, spawns in pairs(SpawnsFolder:GetChildren()) do
spawns.Name = tostring(i)
end
end
Also another thing I was not understanding is that why were the loops inside of other loops? I think it’s better if it’s done like this if it doesn’t really need to be ran every frame but just in a consistent manner
There was actually absolutely no reason at all, I was just trying to find another loop alternatives
A loop like mine that I’ve shown would be more efficient as it changes their names every second in 3 separate loops instead of them being nested, is that what you want or does it need to do it faster?
does while wait(0.1) do
cause lag if there’s too much variables?
I’m not sure, cause when you were doing Stepped
it was running every frame, whereas wait(0.1)
does the loop every tenth of a second, ten times a second. If there’s a lot of plates and what not it may cause slight lag when having to rename all of them, but shouldn’t be that much of an issue compared to Stepped
I did this and it still lags, and I get an average 40fps which is lagging, and there was a bit many variables. So How do I make it less lag?
while wait(1) do
-- Checks How Many Plates Are There, Then Rename it
for i, plates in pairs(PlatesFolder:GetChildren()) do
plates.Name = tostring(i)
-- Checks stepping plates
for i, stepPlates in pairs(SteppingPlatesFolder:GetChildren()) do
stepPlates.Name = tostring(i)
for i, spawns in pairs(SpawnsFolder:GetChildren()) do
spawns.Name = tostring(i)
end
end
end
end
Maybe put the for loops separate instead of putting them in each other? I don’t see a reason why you need to put them in each other considering it’s just name changing. Do what I did
while true do
wait(1)
for i, plates in pairs(PlatesFolder:GetChildren()) do
plates.Name = tostring(i)
end
-- Checks stepping plates
for i, stepPlates in pairs(SteppingPlatesFolder:GetChildren()) do
stepPlates.Name = tostring(i)
end
for i, spawns in pairs(SpawnsFolder:GetChildren()) do
spawns.Name = tostring(i)
end
end
2 Likes
Oh thank you so much, I got a stable fps now
1 Like
Anytime! if you have anymore issues don’t be afraid to make another post!
1 Like