Lag spikes when loading new "chunks"

Hello! First of all i need to point out that i’m using :PivotTo() to clone from ServerStorage the new “chunks”.

I’ve been searching and i found out that moving models with :PivotTo() is a bit laggier than only moving using CFrame, but it’s the only way that i could achieve this infinite path made as i was moving with the train.

As you can see on this video, moving the train itself does not affect on the user FPS, but, as i was generating new parts, my FPS was going down and down, probably because of the velocity i was generating it.


And now i am in doubt, it is because of the way that i am moving parts? It is because of the velocity that i am generating it?

In case of curiosity, i am using ModelStreamingBehavior on workspace already, and I made a simply but effective optimizer deleting the parts as it generated a certain quantity.

The main base of the script is this:

ProceduralGen.Event:Connect(function(hitbox)

	for i, End in pairs(workspace.Procedural:GetDescendants()) do
		if End.Name == "End" then
			EndPart = End
		end
	end

	local possibleparts = game.ServerStorage.Parts:GetChildren()
	local randompart = possibleparts[PartsR.random:NextInteger(1, #possibleparts)]

	local NextPart = randompart:Clone()
	NextPart.Parent = workspace.Procedural

	NextPart.PrimaryPart = NextPart.Start
	NextPart:PivotTo(EndPart.CFrame)

	local Sequence = Instance.new("NumberValue")
	Sequence.Parent = NextPart
	Sequence.Name = "Sequence"
	Sequence.Value = 0

	hitbox:Destroy()
	EndPart:Destroy()

end)

There’s some chance it could be the way I designed it? or simply the speed i was generating it?

I was thinking too that it might be solved by making the generated parts longer, but i don’t know if it’ll be effective in long time, as it might have lag spikes when generating one per time.

Feel free to ask any question if needed!

Hi,

Usually generating ‘chunks’ the way that you are shouldn’t be very laggy. It might be the humanoids that you’re placing - they’re known to be less performant that regular parts. Does the issue still happen if you remove the NPCs?

1 Like

Sorry for the delay.

It seems like that the buildings near the generation was causing the lag, i changed where they were and it solved 99% of the lag.

Strangely the ModelStreamingBehavior value was very tiny, and, i did not find any diference between enabled and disabled.

But thank you for trying to help, I appreciate that! :kissing_closed_eyes:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.