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 ="Attachment", charPrimary)
		local charPosAttachment ="Attachment", charPrimary)
		charPosAttachment.Position =, 1, 2) -- position offset

		local petOriAttachment ="Attachment", petPrimary)
		local petPosAttachment ="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
		-- set the network owner to the player, this ensures that the movement is smooth

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

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