Pets not aligning accordingly

Hello. I created and scripted pets for a game that I am working on, but for some reason, the pets won’t be aligning accordingly. Here is a video:
https://streamable.com/rjoe3u
Here is my code:

local button = script.Parent;

local function on_Click()
	local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent;
	
	if script.Parent.Parent.Parent.Name ~= "Wiggle puff" and script.Parent.Parent.Parent.Name ~= "Cat" then
		local tool = game.ReplicatedStorage.InventoryItems:FindFirstChild(script.Parent.Parent.Parent.Name):Clone()

		tool.Parent = workspace
		
		local humanoid = player.Character.Humanoid;

		if button.Text == "EQUIP" then		
			humanoid:UnequipTools()
			
			for _, v in ipairs(script.Parent.Parent.Parent.Parent:GetChildren()) do
				if v:IsA("Frame") then
					v.Inside.TextButton.Text = "EQUIP"

					v.Inside.TextButton.BackgroundColor3 = Color3.fromRGB(85, 170, 0)
				else
				end
			end
			
			button.Text = "UNEQUIP"

			button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)

			humanoid:EquipTool(tool)
		else
			button.Text = "EQUIP"

			button.BackgroundColor3 = Color3.fromRGB(85, 170, 0)

			humanoid:UnequipTools()

			player.Backpack:ClearAllChildren()
		end
	else		
		if button.Text == "EQUIP" then		

			for _, v in ipairs(script.Parent.Parent.Parent.Parent:GetChildren()) do
				if v:IsA("Frame") then
					v.Inside.TextButton.Text = "EQUIP"

					v.Inside.TextButton.BackgroundColor3 = Color3.fromRGB(85, 170, 0)
				else
				end
			end

			button.Text = "UNEQUIP"

			button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
			
			attachment = Instance.new("Attachment");

			attachment.Name = "PetAttachment"

			attachment.Parent = player.Character.PrimaryPart
			
			local pet = game.ReplicatedStorage.InventoryItems:FindFirstChild(script.Parent.Parent.Parent.Name);
			
			clone = pet:Clone();
			
			clone.Parent = workspace
			
			clone.Main.AlignOrientation.Attachment1 = attachment
			
			clone.Main.AlignPosition.Attachment1 = attachment
			
			repeat wait()
				attachment.Position = Vector3.new(1, -4.2, 0) + clone.Main.Size
			until button.Text == "EQUIP"
			
			return
		else
			button.Text = "EQUIP"
			
			button.BackgroundColor3 = Color3.fromRGB(85, 170, 0)
						
			attachment:Destroy()
			
			clone:Destroy()
		end
	end
end;

button.MouseButton1Click:Connect(on_Click)
1 Like

The LookVector of the pet is not its face

1 Like

Oh, well I use body gyros for this. However, I do something like this:

if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") and not isWalking then 
			bodyGyro.CFrame = CFrame.new(newpet.PrimaryPart.Position, plr.Character.HumanoidRootPart.Position)
else
		    bodyGyro.CFrame = plr.Character.HumanoidRootPart.CFrame
end
1 Like

What line are you referring to (or you can just send the line in Code Block)

U have to redo the pet making its face Its front surface or do some rotating white playing (Rotate the attachment) to see what orientation it should have

1 Like

Should I change the attachment’s world orientation?

1 Like

As i said u can Just hit play go From Client then attachment and start changing it orientation

1 Like

I’ll try that in a moment. :+1:

1 Like

Oh well you can use alignments for it and it’ll work. If you want to continue using alignments then follow @kalabgs advice and play around with the orientation until you get it perfect. Body gyros/Body positions are just great for making the pet feel more lively, but there are other solutions :slightly_smiling_face:

1 Like

Okay. Thank you both for responding! :+1: :slight_smile:

1 Like