MouseButton1Click is not a valid member of Frame

I have a list of pets(each of them Frame).
I want - When I click on a pet, the color of the picture changes to red. But i get an error when i try to make - It is like this:

while true do
	local pets = game:GetService("CoreGui")["Pet Index"].PetIndex.Container.ScrollingFrame.Pets:GetChildren()
	
	for _,pet in ipairs(pets) do
		if pet:IsA("Frame") then
			pet.MouseButton1Click:Connect(function()
			pet.Toggle.PetIcon.ImageColor3 = Color3.new(170, 0, 0)
			end)
		end
	end
	wait(0.3)
end

What’s wrong with it?

3 Likes

I believe MouseButton1Click only works on Buttons, Text Buttons, Image Buttons and such.

1 Like

What i need to use for Click on frame?

1 Like

You cannot click on a frame to my knowledge, that’s why the button objects are there.

1 Like

Btw thx. I will create button for this.

1 Like

No problem, good luck developing!

1 Like

Still need little bit help
It’s stuck on change color(If i print i all time got white)

local remove
while true do
	local pets = game:GetService("CoreGui")["Pet Index"].PetIndex.Container.ScrollingFrame.Pets:GetChildren()
	for _,pet in ipairs(pets) do
		if pet:IsA("Frame") then
			pet.Toggle.MouseButton1Click:Connect(function()
				if remove == true then
					pet.Toggle.PetIcon.ImageColor3 = Color3.new(170, 0, 0)
					remove = false
				else
					remove = true
                    pet.Toggle.PetIcon.ImageColor3 = Color3.new(255, 255, 255)
					
				end
			
			end)
		end
	end
	wait(0.3)
end
1 Like

What isn’t happening that should be?

1 Like

I wanna of i press on pet - pet makes Red (img) = that means i Choose this pet for auto Delete. If I press on Red pet - im remove from Delete list. But i dont need help with list, only with change color correctly. (its spam few times and dont work correctly)

1 Like

I didn’t fully understand what you are saying, however it sorta sounds like a debounce issue?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.