Because of the way this loop functions, the game doesn't know which button in the GUI I'm pressing, and I'm not sure how to tell the game which one is being pressed.

for i,v in pairs(game.Teams:GetChildren()) do
	local players = v:GetPlayers()
	local teams = {}
	
	if #players > 0 then
		table.insert(teams,v)
	end
	
	tbtsclone = tbts:Clone()
	tbtsclone.Parent = framef2
	tbtsclone.Name = v.Name
	tbtsclone.Position = UDim2.new(0.254,0,num,0)
	tbtsclone.Text = v.Name
	
	local tag = Instance.new("BoolValue")
	tag.Parent = tbtsclone
	tag.Name = tbtsclone.Name
	
	num = num + 0.06
	
	local textbuttons = framef2:GetChildren()
	
	tbtsclone.MouseButton1Down:connect(function()
		print(tbtsclone.Name)
	end)
	
end

'tbts' is a variable that describes a specific text box and its clones that are generated. Thanks for any help!

3 comments

1

Why not just create a preset of the gui and put a local script inside of the buttons, which will tell the script which button they pressed. Or, you could do a for loop for the buttons and do v.MouseButton1Down.

0

A variant of your idea worked perfectly. Thanks man!

0

Please post it as a solution so I can accept it.