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

How would I pick a random player to be a seeker?

Trying to make it so that it picks an amount of seekers (depending on the variable 'seekers') out of the players randomly. My attempt is below but it makes every player the seeker, even though 'seekers' prints as 1. It's in a while loop.

for i = 1,seekers do
	for i,v in pairs(plrs:GetChildren()) do
		if v.Character:FindFirstChild("Seeker") then v.Character.Seeker.Value = true end
	end
end

2 answers

function chooseSeeker()
	local players = game.Players:GetChildren()
	local seeker = math.random(1, #players)
	print(seeker.Name " was chosen!")
end

2 comments

0

seeker,Name .. " was chosen!"

1

how is this suppose to work? this picks a random amount of seekers, and 'seeker' isnt a player, its a number

local function RandomPlayer()
    local plrs = game:GetService("Players"):GetPlayers() -- use GetPlayers() not GetChildren()
    return plrs[math.random(1, #plrs)]
end

1 comment

0

i already got my old code working

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