I am making a game in which random events occur in the environment or to the player, but for this I need the game to choose a random player every so often.
-
What do you want to achieve? Have a random player chosen every 30 seconds (e.g.).
-
What is the issue? Only one player is selected when executing the code and I don’t know how to implement it.
Here is my code:
local Players = game:GetService("Players")
if #Players:GetPlayers() < 1 then
Players.PlayerAdded:Wait()
end
local RandomPlayer = Players:GetPlayers()[math.random(#Players:GetPlayers())]
print(RandomPlayer)
My code is a Script inside ServerScriptService
Any ideas on how to implement this?
Thanks in advance.