[HELP] Pet System How I Can Detect Player Idle Or Walking

hello, the pet system is also walking to have the pet look at my view vector to look at the torso when he idling to provide I’m working, can you help me?

Code:

local DTS = game:GetService("DataStoreService")
local petData = DTS:GetDataStore("petdatastpreeeeee")
local petsModule = require(game.ServerScriptService.PetSystem.PetsModule)
local RunService = game:GetService("RunService")

game.Players.PlayerAdded:Connect(function(plr)
	local petsFolder = Instance.new("Folder",plr)
	petsFolder.Name = "PetsFolder"
	
	local equippedPetsFolder = Instance.new("Folder",plr)
	equippedPetsFolder.Name = "equippedPets"
	
	local equippedPetCount = Instance.new("NumberValue",plr)
	equippedPetCount.Name = "EquippedPetCount"
	equippedPetCount.Value = 0
	
	local success,errorMessage = pcall(function()
		petData:GetAsync(plr.UserId)
	end)
	
	if success then
		local data = petData:GetAsync(plr.UserId)
		
		if data ~= nil then
			
			for i,v in pairs(data) do
				if petsModule.Pets[v["PetName"]] then
					local NewPet = Instance.new("Folder",petsFolder) 
					NewPet.Name = v["PetID"]

					local PetID = Instance.new("StringValue",NewPet)
					PetID.Name = "PetID"
					PetID.Value = v["PetID"]


					local PetName = Instance.new("StringValue",NewPet)
					PetName.Name = "PetName"
					PetName.Value = v["PetName"]

					local EquipValue = Instance.new("BoolValue",NewPet)
					EquipValue.Name = "EquipValue"
					EquipValue.Value = v["EquipValue"]

				else
					print("Pet Load Failed!")
				end
			end
		else
			print("U no have data!")
		end
	else
		print("U no have data!")
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	if plr:FindFirstChild("PetsFolder") then
		local pets = {}

		for i, v in pairs(plr.PetsFolder:GetChildren()) do
			if v:IsA("Folder") then
				if v:FindFirstChild("PetName") and v:FindFirstChild("PetID") and v:FindFirstChild("EquipValue") then
					pets[v.Name] = {
						["PetID"] = v.PetID.Value,
						["PetName"] = v.PetName.Value,
						["EquipValue"] = v.EquipValue.Value
					}
					
				else
					print("Error Saving Pet")
				end
			else
				print("Error!")
			end
		end
		
		print(pets)
		
		petData:SetAsync(plr.UserId,pets)
	else
		print("Error")
	end
end)

game.ReplicatedStorage.RemoteEvents.EquipPetEvent.OnServerEvent:Connect(function(plr,petname)
	if petsModule.Pets[petname] then
		local newPet = petsModule.Pets[petname].Model:Clone()
		
		newPet.Parent = plr.Character
		
		if plr.Character then
			if plr.Character:FindFirstChild("HumanoidRootPart") then
				newPet:SetPrimaryPartCFrame(plr.Character["HumanoidRootPart"].CFrame)
			else
				local hmndrtprt = plr.Character:WaitForChild("HumanoidRootPart")
				newPet:SetPrimaryPartCFrame(hmndrtprt.CFrame)
			end
			else
		end
		
		
		local BP = Instance.new("BodyPosition",newPet.PrimaryPart)
		BP.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		
		local BG = Instance.new("BodyGyro",newPet.PrimaryPart)
		BG.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
		
		while wait() do
			
			if plr.Character then
				if plr.Character:FindFirstChild("HumanoidRootPart") then
					BG.CFrame = plr.Character["HumanoidRootPart"].CFrame
					BP.Position = plr.Character["HumanoidRootPart"].Position + Vector3.new(2,2,3)
					else
				end
				else
			end
		end
	else
		plr:Kick("Exploit Detected!")
	end
end)

bumped

You could detect if not Humanoid.Running.

If Humanoid.Running then

-- Code
elseif not Humanoid.Running then

-- Code
end