Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Random Player Select GUI?

Asked by 7 years ago
Edited 7 years ago

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

1 answer

Log in to vote
0
Answered by 7 years ago

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

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

You must then choose via random with math.random

1Chosen = people[math.random(1, #people)]
2--Do whatever with the chosen player after this line
0
I tried to use | script.Parent.Text = Chosen | after this, but it doesnt works. Can you help me? HeisukeKexji 8 — 7y
0
@HenriqueMentzViel "Chosen" is the physical player, you can't set the player as a textbox, what are you trying to do exactly? ninja_eaglegamer 61 — 7y
0
@ninja_eaglegamer Sorry, I speak little english. TextLabel = Name of player. (Chosen) HeisukeKexji 8 — 7y
0
nvm, got it HeisukeKexji 8 — 7y
Ad

Answer this question