Destroying all UICorners

I want to get rid of all UICorners inside orangframe with the click of a textbutton, seemed pretty simple at first until I had this problem.
I was originally gonna try to make a local script like this:

local plrui = game.Players.LocalPlayer.PlayerGui

script.Parent.MouseButton1Click:Connect(function()
	local children = plrui.MainUI.orangframe:GetDescendants()

	for _, v in ipairs(children) do
		if v:IsA("UICorner") then
			print("BOO KILL IT WITH FIRE")
			v:Destroy()
		end
	end
end)

Whats the issue then?

Well, lets say my orangframe looks like this:

image

My original script only removes the UICorner thats parent property is orangframe. I can’t make it so it does v:GetDescendants() or else it will error with this message:

Here's that script
local plrui = game.Players.LocalPlayer.PlayerGui

script.Parent.MouseButton1Click:Connect(function()
	local children = plrui.MainUI.orangframe:GetDescendants()
	
	for _, v in ipairs(children) do
		if v:IsA("UICorner") then
			print("BOO KILL IT WITH FIRE")
			v:Destroy()
		else
			local extrachild = v:GetDescendants()
			if extrachild:IsA("UICorner") then
				print("REALLY KILL IT WITH FIRE")
				extrachild:Destroy()
			end
		end
	end
end)

I don’t wanna hardcode it because I’ll definetely add more in the future of developing my game. What do I do?

Try this?

local plrui = game.Players.LocalPlayer.PlayerGui

script.Parent.MouseButton1Click:Connect(function()
	local children = plrui.MainUI.orangframe:GetDescendants()

	for _, v in children do
		if v:IsA("UICorner") then
			print("BOO KILL IT WITH FIRE")
			v:Destroy()
		end
	end
end)

1 Like

Now I feel stupid. Thanks a lot tho!

1 Like

No problem :+1: !

(charrrrrrrrrrr)

1 Like

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