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

Random Player Select GUI?

i have the gui done, but i have no idea what can i do. help?

1 answer

✓ Accepted answer

First You need to make a list specifically for the players that are online

while true do
	people = {}
	for i, player in pairs(game.Players:GetPlayers()) do
		--GetPlayers() grabs all the players within the list
		if player and player.Character then
			--Checks to make sure the person is completely loaded into the game
			local humanoid = player.Character:WaitForChild("Humanoid")
			if humanoid and humanoid.Health > 0 then
				--Does the same as done before
				table.insert(people,player)
			end
		end
	end
end

You must then choose via random with math.random

Chosen = people[math.random(1, #people)]
--Do whatever with the chosen player after this line

4 comments

0

I tried to use | script.Parent.Text = Chosen | after this, but it doesnt works. Can you help me?

0

@HenriqueMentzViel "Chosen" is the physical player, you can't set the player as a textbox, what are you trying to do exactly?

0

@ninja_eaglegamer Sorry, I speak little english. TextLabel = Name of player. (Chosen)

0

nvm, got it

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