I have tried to make the pet walk instead of hovering but it still hovers and does not work and i can not add animations to it

local rs = game:GetService("ReplicatedStorage")
local config = require(rs:WaitForChild("CONFIGURATION"))

function createFunc(plr:Player, equippedValue:ObjectValue)

	if plr and equippedValue.Parent == plr.PetsEquipped and equippedValue.Value ~= nil then

		local char = plr.Character
		if char and char.Humanoid.Health > 0 then

			local petToCreate = equippedValue.Value

			local newPet = petToCreate:Clone()

			local primaryPart = newPet.PrimaryPart or newPet:WaitForChild("Base")
			newPet.PrimaryPart = primaryPart
			newPet:PivotTo(char.HumanoidRootPart.CFrame)

			for _, part in pairs(newPet:GetDescendants()) do
				if part:IsA("BasePart") then
					part.Anchored = false
					part.CanCollide = false

					if part ~= primaryPart then
						local wc = Instance.new("WeldConstraint")
						wc.Part0 = primaryPart
						wc.Part1 = part
						wc.Parent = part
					end
				end
			end

			local atch0 = Instance.new("Attachment")
			atch0.Name = "Attachment0"
			atch0.Parent = primaryPart

			local ap = Instance.new("AlignPosition")
			ap.MaxForce = math.huge
			ap.MaxVelocity = 20
			ap.Mode = Enum.PositionAlignmentMode.OneAttachment
			ap.Attachment0 = atch0
			ap.Position = char.HumanoidRootPart.Position
			ap.Parent = primaryPart

			local ao = Instance.new("AlignOrientation")
			ao.MaxTorque = math.huge
		    ao.Mode = Enum.OrientationAlignmentMode.OneAttachment
			ao.Attachment0 = atch0
			ao.CFrame = char.HumanoidRootPart.CFrame
			ao.Parent = primaryPart

			equippedValue["LINKED PET"].Value = newPet
			newPet.Parent = char:WaitForChild("EQUIPPED PETS")

			repeat game:GetService("RunService").Heartbeat:Wait() until primaryPart.Parent.Parent == char["EQUIPPED PETS"]
			primaryPart:SetNetworkOwner(plr)
		end
	end
end

return createFunc

Please provide images and or videos.


heres the image

As you can see it still floats and when i put the animation in the individual pet or npc it still floats and the animation doesnt play

Any ideas? on what i should do

So what you want is the pet will detect a surface below it and then will stand on it and play walkAnimation, idleAnimatiom, etc…, right?

yes that is what i want to happen along with no more floating

Okay in that case, things like detect what below you should be done with raycasting. The idea here is you use a loop to raycast if there’s anything below the pet or not. But if the ground that the raycast detect is too far away from the character, the pet will stay hovering

This script is for detecting surface below it

local rcastprms = RaycastParams.new()
rcastprms.FilterDescendantsInstances = {ThingsThatIWantToIgnore}
rcastprms.FilterType = Enum.RaycastFilterType.Exclude
rcastprms.RespectCanCollide = true -- idk, probably can help
local groundDetected = false
while newPet do
   wait(0.1) -- how often do i detect the ground?
   local raycast = Workspace:Raycast(newPet.PrimaryPart.Position,(newPet.PrimaryPart.Position - Vector3.new(0,Height,0)) - newPet.PrimaryPart.Position,rcastprms)
   if raycast and groundDetected == false and raycast.Distance <= HowLongDoIWantTo then -- replace HowLongDoIWantTo to a specific number that you wants the pet to detect the surface, if the surface its detected is too low then it will stay floating
      groundDetetced = true
      newPet.PrimaryPart.Position = raycast.Position + Vector3.new(0,HeightOfThePew,0) -- replace this with the distance between the center of the pet to the highest point in Y axis of the pet to prevent the pet clipping through the surface
   elseif not raycast then
      groundDetected = false
      -- change the pet poisition back to normal at here
   end
end

Of course the script above is a example and i can see that you changed the pivot of the pet to character humanoidrootpart so in order to make this script works, you have to adjust some of its properties by yourself.

And if you want it to play animations create a AnimationController inside the pet, skip this step if you’re already done that! You need to add 4 motor6d’s which connect the primary part of the pet to 4 of its limbs in order to make animations of it. If you get too confused i can explain it to you one more time. But if you already tried this method and it didn’t work out, i don’t really know more.