im trying to make a sign that chooses a random player and displays their display name username and account age on a sign but it doesnt do anything and no errors anyone help?
code:
local players = game.Players:GetChildren()
while true do
local chosenplr = players[Random.new(1, #players)]
if chosenplr then
script.Parent.Text = chosenplr.DisplayName .. "'s (@".. chosenplr.Name .. ") Account is ".. chosenplr.AccountAge.. " Days Old!"
wait(1)
end
wait(1)
end
Move the local players = game.Players:GetChildren() into the loop. Since it’s outside of the loop, it’s only getting the players one time when the script first runs (an empty table).
In addition to Wizard’s observation, you’re using Random incorrectly.
local rng = Random.new() -- Create a generator with optional seed
...
local chosenplr = players[rng:NextInteger(1, #players)] -- Generate int from range
while true do
local players = game.Players:GetChildren()
local chosenplr = players[Random.new():NextInteger(1, #players)]
if chosenplr then
script.Parent.Text = chosenplr.DisplayName .. "'s (@".. chosenplr.Name .. ") Account is ".. chosenplr.AccountAge.. " Days Old!"
wait(1)
end
wait(1)
end