Pet animation not playing

You see where the pet animation function is , yea that function is not playing/ working and I wanted to know why

Server script

local CD = script.Parent -- click detector 
local Hitbox = script.Parent.Parent
local Health = Hitbox.Parent.Health


	local function DetectClick(playerWhoClicked)
		-- CD function
		local amountequuippedvalue = plr.PlayerGui.Inventory.LowerInvFrame.AmountEquipped.AmountEquippedValue-- value used to track the specified amount of pets equipped
		local character = playerWhoClicked.Character:GetChildren() or playerWhoClicked.CharacterAdded:Wait():GetChildren()-- getting char

		for _,pet in pairs(character) do

			if pet ~= nil then 
				if pet:IsA("Model")  then
					-- if can a print, it will print the pet name ex:Dragon 
					print("Pet Found")


					local alignPosition = pet:WaitForChild("AlignPosition")
					local alignOrientation = pet:WaitForChild("AlignOrientation")
					local attachmentpet = pet.PetHitBox:WaitForChild("Attachment")
					local atttachmentTarget = Hitbox.Attachment
					-- all these attachments and constrainst were created before hand
					attachmentpet.Parent = pet.PrimaryPart

					alignPosition.Attachment0 = attachmentpet
					alignPosition.Attachment1 = atttachmentTarget
					alignPosition.Parent = Hitbox
					-- for positioning the pet 
					alignOrientation.Attachment0 = attachmentpet
					alignOrientation.Attachment1 = atttachmentTarget
					alignOrientation.Parent = Hitbox
					-- for rotating the pet

					if amountequuippedvalue.Value == 1 then 
						atttachmentTarget.Position =,0,4) 
					elseif amountequuippedvalue.Value == 2 then 
						atttachmentTarget.Position =,0,0) 
						atttachmentTarget.Orientation =,87,0)
					elseif amountequuippedvalue.Value == 3 then 
						atttachmentTarget.Orientation =,185,0)
						atttachmentTarget.Position =,0,-4)
					elseif amountequuippedvalue.Value == 4 then 
						atttachmentTarget.Position =,0,0)
						atttachmentTarget.Orientation =,-90,0)
					elseif amountequuippedvalue.Value == 5 then 
						atttachmentTarget.Position =,0,3)

						local function petAnimation()

							local atttachmentTarget = Hitbox.Attachment
							while Health.Value <= 0 do 
								pet.CFrame = pet.CFrame + pet.CFrame.LookVector * 2
								pet.CFrame = pet.CFrame + pet.CFrame.LookVector:Inverse() * 2





				print("There was a issue with the pet loading")


		--search char for Groups

		--remote event
		-- pet in LOCAL SCRIPT transfers to SERVER SCRIPT(So everybody can see the pet attacks and animations, and for the player to get the coins ) 

		-- remote event code
		-- step1: make pet pivot to chest, then make animations while damage is being done, and do if damage then coins pop and SFX tho and leaderstats


What animation are you going for, because from the looks of it

this is just going to wait 1 second, set the pet’s cframe, then instantly reset it, maybe moving the wait(1) to between the 2nd and 3rd lines?

1 Like