Pet Sending System Help

Hello, developers!

I have made a wonderful pet sending system, where you click on a part, and it will send the pet to it. The problem is, it doesn’t seem to work, without errors! Here’s the code, any help is appreciated!:

local function sendToPile(Pet)
	local Part = script.Parent.Parent.Parent.PetPart
	local RootPart = Pet:WaitForChild("RootPart")
	local TweenService = game:GetService("TweenService")
	local Tween = TweenService:Create(RootPart, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {CFrame = Part.CFrame})
end

script.Parent.MouseClick:Connect(function(PlayerWhoClicked)
	local PetsFolder = PlayerWhoClicked.Character:FindFirstChild("Pets")
	local EquippedPet
	
	if not PetsFolder or PetsFolder:GetChildren() == nil then return end
	
	for Index, Pet in ipairs(PetsFolder:GetChildren()) do
		if Pet:FindFirstChild("Equipped") == true then
			EquippedPet = Pet
			break
		else
			continue
		end
	end
	
	sendToPile(EquippedPet)
end)

Thanks in advance! :slightly_smiling_face:

1 Like

add a .Value after the FindFirstChild

1 Like

Ah, I totally overlooked that. Thanks, I’ll let you know if it works!

1 Like

Sadly, it doesn’t work. :thinking:
Thanks for the help though!

1 Like

Click on a part or person? I don’t understand.

I realized I forgot to play the tween… :laughing:

2 Likes

bruh moment
sheeeshhhhhhhhhhhhh

2 Likes

I found the root cause:

	if not PetsFolder or PetsFolder:GetChildren() == nil then return end
	
	for Index, Pet in ipairs(PetsFolder:GetChildren()) do
		if Pet:FindFirstChild("Equipped") == true then
			EquippedPet = Pet
			break
		else
			continue
		end
	end
	
	sendToPile(EquippedPet)
end)

No idea really how to check if GetChildren is nil.

thats strange, it shouldve sent an error stating it was nil.

It says “attempt to index nil with GetChildren”, even though there are children.