Pet following system pets fly off when shift locked is enabled and player strafes

I would like to fix the issue where the pets fly off when shift lock is enabled, there is an attachemnt on the player for each pet’s goal location and another attachment in the pet, align orientation and position are both used

Gif of what happens normally then with shift lock enabled: https://gyazo.com/6c14b27678da2c50a4502aacb3a63692
Gif only with shift lock enabled: Anime Skibidi Simulator - Roblox Studio (gyazo.com)

I’ve looked all around on the dev forum for topics that might fix my problem but there doesn’t seem to be any

local CurrentPets = {}
local Offsets = GenerateOffsets(180, 15) -- 2nd arg is the amount of pets
local Movers = script:GetChildren()

local function SpawnPets(HumanoidRootPart)
	if CurrentPets and #CurrentPets > 1 then
		for _, Pet in CurrentPets do
			if typeof(Pet) == "Instance" then
				Pet:Destroy()
			end
		end
	end
	local Pets = {}
	local CFrames = {}
	local HumanoidRootCFrame = HumanoidRootPart.CFrame
	for i, Point in Offsets do
		local Pet = PetModels.Pet:Clone()
		Pet.Name = i
		Pet.Parent = workspace.Terrain
		Pets[i] = Pet.PrimaryPart
		local LookCF = CFrame.lookAt((HumanoidRootCFrame*Point).Position, HumanoidRootCFrame.Position)
		for _, Mover in Movers do
			Mover = Mover:Clone()
			Mover.Attachment0 = Pet.PrimaryPart.Attachment
			local Attach = Instance.new("Attachment")
			Attach.WorldCFrame = LookCF
			Attach.Position =  Point.Position
			Attach:SetAttribute("OriginalOffset",Point.Position)
			Attach.Parent = HumanoidRootPart
			Mover.Attachment1 = Attach
			Mover.Parent = Pet.PrimaryPart
		end
		Pet.PrimaryPart.Anchored = false
		CurrentPets[#CurrentPets + 1] = Pet
		CFrames[i] = LookCF
	end
	
	workspace:BulkMoveTo(Pets, CFrames)
end

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

SpawnPets(Character:WaitForChild("HumanoidRootPart"))

Player.CharacterAdded:Connect(function(Character)
	SpawnPets(Character:WaitForChild("HumanoidRootPart")) -- Creates Pets
end)

The align position and orientation under the script are just the default ones that are created when doing instance.new() [yes I have tried all combinations of the properties and the pets are mass less, collision off and minimum density]

Any help would be appreciated

2 Likes

Do you need/want shift locked in your game for a specific reason? You could always remove it if you can’t find another solution that fixes your issue.

1 Like

I’ve done a temporary solution by disabling shift lock but I would prefer to fix this bug and have it in my game

2 Likes