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
wait(3) --if Player isnt connected and script is working then .. script cant find randomplayer. randomPlayer = game.Players:GetChildren() [math.random(1,#game.Players:GetChildren())] game.ReplicatedStorage.Variables.ChosenPlayer.Value = randomPlayer game.ReplicatedStorage.Variables.ChosenPlayerName.Value = randomPlayer.Name