local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] print(randomPlayer) game.ReplicatedStorage.Talk:FireClient(randomPlayer,"Why the hecc are we all going to the bathroom at the same time!")
It says that player argument must be a Player object but I checked other sources dozens of times and found the same script/method. Please help! I know that it is nil but i don't quite know why because I'm pretty sure I did everything correctly.
GetChildren
would be the way to go for me, so something like this should be fine:
local Players = game.Players:GetChildren() local RandomPlr = Players[math.random(1,#Players)] print(RandomPlr.Name) -- I think you were trying to print the name which you need to define...
Hope this worked.
Try making an earlier variable and test. Maybe roblox does not like turning a function straight into an array:
local PlayerArray = game.Players:GetPlayers() local randplayer = PlayerArray[math.random(1,PlayerArray)]
If it doesn’t work, then:
local randplayerobject = game.Players:FindFirstChild(randplayer)
I dont know if GetPlayers returns objects or strings. But one thing I do know is that I don’t have access to my pc rn so i can not test.