Updating any weld c0 on a gun with a visible morph on the character drops frames

basically whenever i update the C0 of a weld in a gun with a visible morph on the character, render in micro profiler shoots really high up and frames drop
in the vid the P90 doesn’t lag because it doesnt eject shells (retracting the bolt/slider to eject shells is updating the bolt/slider weld’s C0) and the minigun lags a lot cuz im updating the barrel’s weld C0 to spin it
if i make the morph transparent it completely fixes the problem and acts normal again (as seen in the video) but i dont understand why updating a gun weld’s C0 will increase render time only when a morph is on the character and visible
Lowering graphics doesnt help, disabling shells doesn’t help, and im pretty sure its not cuz the morph is welded to the player because when the morph is transparent and still welded to the player it doesn’t lag

Here’s the code for welding the tool

	local function weldTableToPart(weldTable, weldTo)
		for _,v in pairs(weldTable) do
			if v:IsA("BasePart") then
				if v ~= weldTo then
					local weld = Instance.new("Weld")
					weld.Part0 = v
					weld.Part1 = weldTo
					weld.C0 = v.CFrame:Inverse()
					weld.C1 = weldTo.CFrame:Inverse()

					weld.Name = v.Name.."Weld"
					weld.Parent = weldTo
				end

				v.Anchored = false
				v.CanCollide = false
				v.Massless = true
			end
		end
	end
	
	
	--\\ welding tool
	weldTableToPart(tool:GetDescendants(), handle)

Here’s the code for spinning the minigun barrel

if spinSpeed.Value <=0 then
	spawn(function()
		while spinSpeed.Value >0 do
			barrelModelWeld.C0 = CFrame.Angles(math.rad(spinSpeed.Value), 0, 0) * barrelModelWeld.C0
			runService.Heartbeat:Wait()
		end
	end)
end

And here’s the code for retracting the bolt

local contractTween = tweenService:Create(boltWeld, TweenInfo.new(settings.misc.shellEjection.ejectTime / 2, Enum.EasingStyle.Linear), {C0 = boltWeld.C0 * CFrame.new(boltWeld.Part0.Size.X / divider, 0, 0)})
contractTween:Play()

contractTween.Completed:Connect(function()
	ejectShell(not pistol and boltWeld.Part0.CFrame * CFrame.new(-boltWeld.Part0.Size.X / divider, 0, 0) or boltWeld.Part0.CFrame, settings)

	local retractTween = tweenService:Create(boltWeld, TweenInfo.new(settings.misc.shellEjection.ejectTime / 2, Enum.EasingStyle.Linear), {C0 = boltWeld.C0 * CFrame.new(-boltWeld.Part0.Size.X / divider, 0, 0)})
	retractTween:Play()

	retractTween.Completed:Connect(function()
		ejectingShells[weaponHandle] = nil
	end)
end)

I don’t really think this is a code issue but more of a roblox issue but I’m not really sure. Any help would be appreciated, thanks.

fixed the issue by welding parts to the gun via motor6ds and tweening the C0s on the motors instead of welds

1 Like