Pet seems laggy

Hey guys, I created a pet movement system. It works but looks buggy and jittery. Any suggestions to fix it?

local TweenService = game:GetService("TweenService")

game.Players.PlayerAdded:Connect(function(plr)
    local clonedParent = script.Parent:Clone()
    clonedParent.Parent = workspace

    plr.CharacterAdded:Connect(function(char)
        local hrp = char:WaitForChild("HumanoidRootPart")
        local connection
        connection = game:GetService("RunService").Heartbeat:Connect(function()
            if not char.Parent then
                connection:Disconnect()
                return
            end
            local goal = { CFrame = hrp.CFrame * CFrame.new(-4, -1.6, 0) }
            local tween = TweenService:Create(clonedParent, TweenInfo.new(0.1), goal)
            tween:Play()
        end)
    end)
end)

The pet clones when player joins and then tweens every frame. Any ideas to make it smoother?

When it comes to smooth visuals, it would involve using local scripts to do it, which is often complex because it would have to be displayed equally to every client.

If I were to be in this case, I would make a folder named Pets inside of character model and put in the pets I want to tween. Then in a local script, I get every players’ character like this:

local function CharacterAdded(character)
-- Code here
end

local function PlayerAdded(player)
if player.Character then CharacterAdded(player.Character); end
player.CharacterAdded(CharacterAdded)
end

for _, player in pairs(PlayersService) do
PlayerAdded(player)
end

PlayersService.PlayerAdded(PlayerAdded)

In CharacterAdded, I would run a loop to get every pets from the Pets folder and begin tweening them.

I would also make player characters persistent if streaming is enabled to be safe about it.

Hope you find this helpful.

I recommend to use align position for this.
It also makes the pet follow the player accurately without delay on the client too.
I changed your code to do this:

game.Players.PlayerAdded:Connect(function(plr)
	local clonedParent = script.Parent:Clone()
	clonedParent.Parent = workspace

	plr.CharacterAdded:Connect(function(char)
		local hrp = char:WaitForChild("HumanoidRootPart")
		local connection
		connection = game:GetService("RunService").Heartbeat:Connect(function()
			if not char.Parent then
				connection:Disconnect()
				return
			end
			
			local att0 = Instance.new("Attachment")
			att0.Parent = clonedParent
			
			local att1 = Instance.new("Attachment")
			att1.Parent = hrp
			att1.CFrame = CFrame.new(-4, -1.6, 0)
			
			local alingpos = Instance.new("AlignPosition")
			alingpos.Parent = clonedParent
			alingpos.Attachment0 = att0
			alingpos.Attachment1 = att1
			-- Tweak the properties to your liking.
			
			local alingrot = Instance.new("AlignOrientation") -- Stops the pet from spinning around uncontrollably.
			alingrot.Parent = clonedParent
			alingrot.Attachment0 = att0
			alingrot.Attachment1 = att1
			-- Tweak the properties to your liking.
			
			clonedParent:SetNetworkOwner(plr)
		end)
	end)
end)

Don’t forget to set the network ownership if the pet is gonna run physically (as in unanchored.)

Didn’t think about that!
I’ll change the code.

i tried adding that but it was same so i removed it


heres how pet looks