Pet following Floating

local function playerAdded(player)
	local function characterAdded(character)
		local pet = somePet:Clone()

		local charPrimary = character.PrimaryPart
		local petPrimary = pet.PrimaryPart

		local charOriAttachment = Instance.new("Attachment", charPrimary)
		local charPosAttachment = Instance.new("Attachment", charPrimary)
		charPosAttachment.Position = Vector3.new(2, 1, 2) -- position offset

		local petOriAttachment = Instance.new("Attachment", petPrimary)
		local petPosAttachment = Instance.new("Attachment", petPrimary)


		local alignPosition = alignPositionTemplate:Clone()
		alignPosition.Attachment0 = petPosAttachment
		alignPosition.Attachment1 = charPosAttachment
		alignPosition.Parent = petPrimary

		local alignOrientation = alignOrientationTemplate:Clone()
		alignOrientation.Attachment0 = petOriAttachment
		alignOrientation.Attachment1 = charOriAttachment
		alignOrientation.Parent = petPrimary

		pet.Parent = workspace
		petPrimary:GetNetworkOwner(player)
		-- set the network owner to the player, this ensures that the movement is smooth
		
		
	end

	characterAdded(player.Character or player.CharacterAdded:Wait())
	player.CharacterAdded:Connect(characterAdded)
end

How would I make a pet floating animation. LIke the x value changing. I got this script from dev forum.

You can use Tween Or you can make an Animation For The Pet.
With Animation, You Can Get the current state of the humanoid, if the state is walking, play the pet animation.
You Can Read This : StateChanged