Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I don't understand why its not working, trying to make it pick a random player?

I don't understand why its not working, trying to make it pick a random player from Players and making the Value "Asking" true

local QuestionParts = game.Workspace.QuestionParts
local TotallyNotRemotes = game.ReplicatedStorage.TotallyNotRemotes
local AskGui = game.Lighting
local ServerGui = game.Lighting


game.Players.PlayerAdded:connect(function(player)
	
	
function chooserandom()
 local players = game.Players:GetChilderen()
 print (#players)
 if #players > 2 then
  local RandomPlayer = players[math.random(1,#players)]

	RandomPlayer.Asking.Value = true


chooserandom()

 end
end
	
end)

1 answer

How exactly are you figuring this will work? You are calling "chooserandom" inside the function "chooserandom". Your code should be like this. Just eddited the structure a bit.

local QuestionParts = game.Workspace.QuestionParts
local TotallyNotRemotes = game.ReplicatedStorage.TotallyNotRemotes
local AskGui = game.Lighting
local ServerGui = game.Lighting

function chooserandom()
 local players = game.Players:GetChilderen()
 print (#players)
 if #players > 2 then
  local RandomPlayer = players[math.random(1,#players)]

    RandomPlayer.Asking.Value = true



 end
end

game.Players.PlayerAdded:connect(function()
	chooserandom()
end)



This discussion is preserved as it was. New answers, comments, and votes are closed.