Getting a random player

on my previus pos ive tried everything that peaple suggested but still get this error and its a server script

attempt to call missing method ‘GetPlayers’ of table

local players = game:GetService("Players"):GetPlayers().

local pickedPlayer = players[math.random(1, #players)]. -- heres error

It’s because the Players variable will be defined by the players in the server at the moment the server opens so it will error because there isn’t any player

no I have a wait 60 now_______

Where did you put the wait in the script ?

not really a wait I just have a getproperty change value wich goes off after a minute

Can you send the full script please ?

There is a period at the end of the first line. Is that the problem?
As well as the second.

Can you print game:GetService(“Players”)

There’s a period at the end of both, remove them and it should work

.

try this

local Players = game:GetService("Players")

-- Wait for the Players service to load if it's not available yet
while not playersService do
    Players= game:WaitForService("Players")
end

local players = playersService:GetPlayers()

if #players > 0 then
    local pickedPlayer = players[math.random(1, #players)]
    -- your code goes here
else
    print("No players found.")
end