Help with pet stuttering

Hey there,

I am trying to rework the way my pets move, and I am having some trouble moving them smoothly.
I am using attachments now instead of previously using tweens.

The issue:

Explorer:
Screenshot 2021-12-23 112205

Code:

local Object = script.Parent
local NAME = Object.NameValue
local pet = Object.PrimaryPart.Position
wait(3)
local character = NAME.Value
local player = game.Players:GetPlayerFromCharacter(character)
if NAME.Value ~= nil then
	script.Parent.Head.AlignOrientation.Attachment1 = character:WaitForChild("Head").NeckRigAttachment
	script.Parent.Head.Anchored = false
	script.Parent.Head.AlignPosition.Attachment1 = character:WaitForChild("Head").PetAttachment
else
	Object:Destroy()
end

function newCharacter(character)

	Object:Destroy()
end
player.CharacterAdded:Connect(newCharacter)

function onPlayerLeaving(player)

	if player.Name == character.Name then
		Object:Destroy()
	end
end

game.Players.PlayerRemoving:Connect(onPlayerLeaving)

--script.Parent.Head.Anchored = false
local player = player.Character.Head ---- player here
local pet = Object.PrimaryPart ---- pet position

ds = 3 --- how far player 
while true do wait(0.5)
	local far = (pet.Position - character.Head.Position).Magnitude
	if far >= ds then
		pet.CFrame = player.CFrame
	end
end	

What is really strange is that I have rigidity enabled for the alignPosition
Screenshot 2021-12-23 112948

I have no clue why it is doing this, any help will be appreciated!

Try doing this

Object.PrimaryPart:SetNetworkOwner(nil)
1 Like
local pet = Object.PrimaryPart.Position
local pet = Object.PrimaryPart

You shouldn’t use a name for a variable that you have used before.

Just change the NetworkOwner as @KillzIsSomeRandomGuy said