Game-killing levels of lag caused by tools forcing streaming

When a player’s character is parented to a model (which is required in our game for movement syncing with said model), equipping any tool that contains a Handle (even if it’s just the Handle alone) causes the parent model to briefly stream in for all clients. This occurs even when the model is way outside their streaming radius and the clients are not marked as a “PersistentPlayer” for that model. It also doesn’t seem to matter if the tool’s handle is located far away before being equipped. This issue also occurs in Atomic streaming mode.

The model appears to stream in for a very brief moment before streaming back out, despite the tool remaining equipped. Rapidly equipping and unequipping the tool causes the model to repeatedly stream in and out, which can cause extreme lag if the model is complex.

A private message is associated with this bug report

Apparently staff thinks this issue doesn’t “have a direct impact on the operational integrity of your experience or of Studio,” (a direct quote).

This issue causes debilitating lag for our players just from one player equipping and unequipping tools. I’m confused as to how that doesn’t have a direct impact on the operational integrity of our experience.

Thanks for bringing this to our attention. We are looking into options for improving this behavior.

The lag is particularly problematic in the repro place you provided since the character model is being parented under a large atomic model. This is causing the parent atomic model to be streamed in. If the parent model was not Atomic or PeristentPerPlayer this lag would not be as bad. Or if the character model was left under Workspace and not reparented under the model. Are either of those workaround feasible in your situation?

In the game there are separate airports, and we set the planes to persistent for the players that are at the same airport as the plane at the time. We do this in order to avoid some issues with animating them. In the future we plan to refactor a lot of the old code so that we won’t have to do this for the entirety of such complex models, but that’d require too many changes for us to feasibly do in a reasonable time at the moment.

We parent the character model to the model in order to easily force the character(s) to move along with the model whenever it’s pivoted. We do need this behavior, but the current method is more of a convenience. I think as a workaround we could just manually pivot the character(s) along with the model as the airplane is tweening. A bit less convenient but that should work!

Edit: Thought about it a bit more and this wouldn’t be super feasible for us either, since it’d basically lock character movement as the planes taxi around the airports. Would be a lot more inconvenient since we’d have to work in some sort of custom character movement controller to account for this. :sweat_smile:


I do have a sort of workaround specifically for our game - since our tools are more for aesthetic purposes and aren’t actually coded tools, we can overwrite their behavior a little bit. Obviously we would rather not have to do a workaround like this, but it works.

local Players = game:GetService("Players")

local HOLD_ANIMATION_ID = "rbxassetid://8096088927"

local function getToolContainer(character: Model)
	local toolContainer = character:FindFirstChild("toolContainer")
	if not toolContainer then
		toolContainer = Instance.new("Folder")
		toolContainer.Name = "toolContainer"
		toolContainer.Parent = character
	end
	
	return toolContainer
end

local function createWeld(part0: BasePart, part1: BasePart): WeldConstraint
	local weld = Instance.new("WeldConstraint")
	weld.Part0 = part0
	weld.Part1 = part1
	weld.Parent = part0
	return weld
end

local function handleTool(tool: Tool)
	if not tool:IsA("Tool") or not tool.RequiresHandle then 
		return 
	end

	tool.RequiresHandle = false
	
	local handle: BasePart? = nil

	local parts: {BasePart} = {}
	local welds: {WeldConstraint} = {}
	
	local animationTrack: AnimationTrack?

	for _, descendant in tool:GetDescendants() do
		if descendant:IsA("BasePart") then
			if descendant.Name == "Handle" then
				handle = descendant
			end
			
			table.insert(parts, descendant)
			descendant.Parent = nil
		end
	end

	tool.Equipped:Connect(function()
		local character = tool.Parent
		if not character then return end

		local toolContainer = getToolContainer(character)

		for _, part in parts do
			part.Parent = toolContainer
		end

		if handle then
			local rightHand = character:FindFirstChild("RightHand")
			local rightGripAttachment = rightHand and rightHand:FindFirstChild("RightGripAttachment")

			if rightHand and rightGripAttachment and rightHand:IsA("BasePart") then
				local targetCFrame = (rightGripAttachment :: Attachment).WorldCFrame * tool.Grip
				handle.CFrame = targetCFrame
				handle.Anchored = false
				
				local weld = createWeld(handle, rightHand)
				table.insert(welds, weld)
			else
				warn("RightGripAttachment or RightHand not found")
			end
		end

		-- Play animation if not already loaded
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")
		if animator and not animationTrack then
			local anim = Instance.new("Animation")
			anim.AnimationId = HOLD_ANIMATION_ID
			animationTrack = animator:LoadAnimation(anim)
			animationTrack.Priority = Enum.AnimationPriority.Action
		end
		
		if animationTrack then
			animationTrack:Play()
		end
	end)

	tool.Unequipped:Connect(function()
		for _, joint in welds do
			joint:Destroy()
		end
		
		welds = {}

		for _, part in parts do
			part.Parent = nil
		end

		if animationTrack and animationTrack.IsPlaying then
			animationTrack:Stop()
		end
	end)
end

local function monitorBackpack(player: Player)
	local function onToolAdded(child: Instance)
		if child:IsA("Tool") then
			handleTool(child)
		end
	end

	local function onBackpackReady()
		local backpack = player:FindFirstChildWhichIsA("Backpack")
		if not backpack then return end

		backpack.ChildAdded:Connect(onToolAdded)

		for _, tool in backpack:GetChildren() do
			if tool:IsA("Tool") then
				handleTool(tool)
			end
		end
	end

	if not player.Character then
		player.CharacterAdded:Wait()
	end

	task.defer(onBackpackReady)
end

for _, player in Players:GetPlayers() do
	monitorBackpack(player)
end

Players.PlayerAdded:Connect(monitorBackpack)

I’m glad someone else brought this issue up. It’s caused by a character bug that conflicts with streaming behavior. I reported it some time ago (Unexpected behavior with atomically loaded characters) and their response was similar, basically, that the issue is unimportant.

The post mentions that this only happens to models the character is parented to, but that’s not the full story. It also occurs with models connected via physics constraints, like welds. In my case, the player sits inside a vehicle, making them part of a single assembly. Equipping a tool causes the atomic vehicle to stream in and out rapidly with no descendants, which is unexpected and results in numerous confusing errors that are difficult to distinguish from actual errors.

I didn’t bring up the performance impact in my post, but I believe it could pose a significant problem for lower-end devices. The way this bug behaves could cause more problems that haven’t been reported yet, and I’d like to once again ask that it be reconsidered for a fix.

We do take this issue seriously and are investigating options to improve this behavior. My suggestion of some possible short-term workarounds for @Scriptos wasn’t meant to indicate that we consider this issue unimportant. We are looking into how we can address this without asking creators to work around it.

As @EmesOfficial pointed out this isn’t just a problem with atomic models, but can occur with collections of instances that are associated due to physics constraints as well. Fundamentally this issue occurs when we have an already replicated instance, typically a tool, that becomes associated with a collection of instances (models, assemblies, or a combination of those). Not sending the rest of the collection is problematic since you could then have an atomic model that is incomplete, or a physics assembly where it is incomplete on the client. Having these incomplete collections on the client can result in undesirable behavior as well.

Thank you to the creators who have raised this issue to us, we aren’t dismissing your concerns and are working on this problem.

Thank you! That’s more than enough acknowledgment. I hope a solution emerges soon, and if there are any questions related to this bug, I’d be more than happy to help :slightly_smiling_face:

Hello!
I hope all is well. I sincerely apologize about the time this bug has taken to be resolved. This has had multiple different reasons, but regardless this simply is too long a period. However, I am here to also notify that this issue should have been resolved. The repro place attached in the message no longer appears to give issues. Please let us know if this issue still occurs in your experience.

Hello Again!

I understand if there is no response or a long pause for a response due to the delay to address this issue. However we also believe this issue to be resolved and would like to either confirm this or stop tracking this internally. If we do not get a response in around a week, I will mark this ticket as resolved. I apologize for the short time frame, and if by chance we falsely close this issue, please reach out again. Thank you.