Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Displaying A Player list on a text button?

Displaying A Player list on a text button I want to make a bunch of text buttons displaying player names. All though this doesnt work if it worked would it be efficient? If not how could I make it?

player = game.Players.NumPlayers
playerRand = math.random(1, #player)
script.Parent.Text = playerRand.Name

1 answer

No. This would not be efficient at ALL. You would have many copies of the same name. You should use this:

-- BEFORE YOU DO ANYTHING, CREATE SLOTS NUMBERED 1 - 8 -- CHANGE 8 TO MAX PLAYERS
player = game.Players.LocalPlayer
players = game.Players:GetChildren()
repeat wait() until player.Character
plrn = 1

for i, v in pairs(players) do
	slot = script.Parent.Parent:FindFirstChild(plrn)-- LOCATION OF SLOT
	slot.Text = v.Name
	slot.MouseButton1Click:connect(function()
		chosenPlayer = game.workspace:FindFirstChild(slot.Text)
		if chosenPlayer then
			-- SCRIPT THAT DOES STUFF TO PLAYER
		end
	plrn = plrn + 1
	end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.