Help changing ui object name if its the same as another

In my game players are able to spawn in ui objects. But if the ui object has the same name as another, it interferes with another script I have. I’ve been making this script for when the player spawns in another ui object, it checks for if the ui object they spawned has the same name as another. But I can’t figure out how to do it right.

local number = 0
	for i, v in pairs(player.PlayerGui.GameGui.Websites[Website]:GetChildren()) do
			number = number + 1
			Clone.Name = Gui..number
		until Clone.Name ~= v.Name

Right now, spawning in your first textbutton it will be called, “TextButton1”. But when spawning a second its also called, “TextButton1”.

Sorry if this didn’t make sense.

Try this.

local number = 0
     number += 1
until not player.PlayerGui.GameGui.Websites[Website]:FindFirstChild(Gui..number)
Clone.Name = Gui..Number
1 Like