Account age sign not changing

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
2 Likes

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).

1 Like

its still doing nothing at all its just showing the text that was already there

1 Like

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
2 Likes

this worked! thanks
full edited script:

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
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.