Help with pet following

Hi there!

I am trying to change up the way I make my pets follow players. Before I used tweening, but doing that constantly across like 10 pets is a little much and can create some lag. So I want to try to use constraints. It was all going great, right up until I tried using AlignPosition.RigidityEnabled. I wanted to try to make it very aligned with the pet, but when covering long distances it(for instance a player spawning in a different world) the pet will not do what it is supposed to do and just drops. Does anyone know any work arounds for rigidityEnabled?

This is the code I used to turn it on if needed

script.Parent.Head.AlignOrientation.Attachment1 = character:WaitForChild("Head").NeckRigAttachment
	script.Parent.Head.Anchored = false
	script.Parent.Head.AlignPosition.Attachment1 = character:WaitForChild("Head").NeckRigAttachment
1 Like

You can use attachments. This is a example

        local pet = game.Workspace.Pet
        local char = plr.Character
		
		pet:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame)
		
		local modelSize = pet.PrimaryPart.Size
		
		local attachmentCharacter = Instance.new("Attachment")
		attachmentCharacter.Visible = false
		attachmentCharacter.Name = "attachmentCharacter"
		attachmentCharacter.Parent = char.HumanoidRootPart
		attachmentCharacter.Position = Vector3.new(1,1,0) + modelSize
		
		local attachmentPet = Instance.new("Attachment")
		attachmentPet.Visible = false
		attachmentPet.Parent = pet.PrimaryPart
		
		local alignPosition = Instance.new("AlignPosition")
		alignPosition.MaxForce = 25000
		alignPosition.Attachment0 = attachmentPet
		alignPosition.Attachment1 = attachmentCharacter
		alignPosition.Responsiveness = 25
		alignPosition.Parent = pet
		
		local alignOrientation = Instance.new("AlignOrientation")
		alignOrientation.MaxTorque = 25000
		alignOrientation.Attachment0 = attachmentPet
		alignOrientation.Attachment1 = attachmentCharacter
		alignOrientation.Responsiveness = 25
		alignOrientation.Parent = pet
		
		pet.Parent = char
4 Likes

you can use this script

local player = player.Character.Head.Position ---- player here
local pet = pet.PrimaryPart.Position ---- pet position
local petplace = Vector3.new(4,-2,4)
ds = 100 --- how far player 
while true do wait(0.5)
	local far =(pet - player ).Magnitude
	if far >= ds then
		pet = player+petplace
end
3 Likes