Hi everyone, Im writting sort of an organized regeneration script, I need help with lag issues

So I created a module that regenerates a characters limbs in sequence fore example, (RightUpperArm > RightLowerArm > RightHand) Its fully customizable such as I can add a custom part to be generated in sequence, the problem is the lag that I receive as Im regenerating

The regeneration animation occurs client sided.

2 Likes

do you mind showing the code responsible for this?

	local Regenerative_Tween = Tween.obj(Piece,"Sine","In",T,{Size = Original_Limb.Size})
				local Regenerative_Weld = Tween.obj(Piece:FindFirstChildOfClass("Motor6D"),"Sine","In",T,{C0 = CFrame.new(0,Original_Limb.Size,0),C1 = CFrame.new(0,0,0)})

				local Regenerative_Weld2 = Tween.obj(Piece:FindFirstChild("Fake"),"Sine","In",T,{C0 = CFrame.new(0,0,0),C1 = CFrame.new(0,0,0)})

		

				local Previous_Limb = Limb1[New_Priority]
				local Models_Limb = Model:FindFirstChild(Previous_Limb)
				for u,v in ipairs(Model:GetDescendants()) do
					if v:IsA("BasePart") then
						if v.Name == LimbName then
							Models_Limb = v 
						end
					end
				end
				table.insert(Limbs[Model.Name][LimbName],Regenerative_Weld)			
				table.insert(Limbs[Model.Name][LimbName],Regenerative_Weld2)			
				table.insert(Limbs[Model.Name][LimbName],Regenerative_Tween)			
				task.spawn(function()
					runservice.RenderStepped:Connect(function()
						if Regenerate_Hold == false then
							Regenerative_Weld:Pause()
							Regenerative_Weld2:Pause()
							Regenerative_Tween:Pause()
						else
							if Regenerate_Hold == true then
								Regenerative_Tween:Play()
								Regenerative_Weld:Play()
								Regenerative_Weld2:Play()
							end
						end
					end)
				end)