Hello, I am encountering an error when I try to run this simple piece of code
randomPlayer = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())]
game.ReplicatedStorage.Variables.ChosenPlayer.Value = randomPlayer
game.ReplicatedStorage.Variables.ChosenPlayerName.Value = randomPlayer.Name
When I enter this
print(game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())])
in the command line, it works fine.
Any ideas on how to fix this? Filtering is enabled.
~ 21_T

2 comments
Could be because the script runs before any player has connected.
WaitForChiks