Pet Script not working

Hello, everybody
I have a script where it fires a remote if the player Equips a pet, but in order for the remote event to fire the script has to pass a few if statements. The issue is that I don’t think the if statements are passed since the output is not running the print about the dog(code below) No errors in output

Local Script

local Equip = script.Parent
local template = script.Parent.Parent.Parent.Parent.Parent




Equip.MouseButton1Click:Connect(function() -- when player clicks Equip, the Equip is a Ui that prompts players
	Equip.Text = "Equipped"
	
	
	local EquippedValue = template:WaitForChild("EquippedValue")
	EquippedValue.Value = "Equipped" -- value in template to store info

	for _, child in pairs(template:GetChildren()) do -- checking all children of template
		if child:IsA("Folder") and child.Name == "Cat"	then 
			
			
			
	elseif child:IsA("Folder")  and child.Name == "Dog" then -- confirming that child is the Dog
				print("Dog is a valid child of template") -- this is print statement i am talking about
						
				
				local ReplicatedStorage = game:GetService("ReplicatedStorage")
					local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
				EquipPet:FireServer() -- then the remote event fires 
	
					
				
				else 
					print("Pet is already Equipped") -- this will not run aswell 
				end 
				end
				end
			
		
	



end)

Screenshot 2022-05-03 181141
Screenshot 2022-05-03 181302
You could see that the Dog is located there and I have clicked Equipped, but the print will not run

You had an extra

end)

in your code, try this and see if you still have any problems.

local Equip = script.Parent
local template = script.Parent.Parent.Parent.Parent.Parent

Equip.MouseButton1Click:Connect(function() -- when player clicks Equip, the Equip is a Ui that prompts players
	Equip.Text = "Equipped"

	local EquippedValue = template:WaitForChild("EquippedValue")
	EquippedValue.Value = "Equipped" -- value in template to store info

	for _, child in pairs(template:GetChildren()) do -- checking all children of template
		if (child:IsA("Folder") and child.Name == "Cat")	then 

		elseif (child:IsA("Folder") and child.Name == "Dog") then -- confirming that child is the Dog
			print("Dog is a valid Parent of template") -- this is print statement i am talking about
			local ReplicatedStorage = game:GetService("ReplicatedStorage")
			local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
			EquipPet:FireServer() -- then the remote event fires 
		else 
			print("Pet is already Equipped") -- this will not run aswell 
		end 
	end
end)
1 Like