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

wont pick random players?

So I am trying to make a dialogue GUI. The script is supposed to pick random players and have them say something but, the only plyer that is picked is the first player that joins. Here's the script that picks random players. If any other scripts need to be included, just tell me.

script

local dialogue = game.ReplicatedStorage.Dialogue
local type = Enum.ThumbnailType.HeadShot
local size = Enum.ThumbnailSize.Size180x180

function Message(player, speech, id)
 dialogue:FireAllClients(player, speech, id)
end
wait(5)
local players = game.Players:GetChildren()
local player = players[math.random(1, #players)]
local id = game.Players:GetUserThumbnailAsync(player.UserId, type, size)

local script

local dialogue = game.ReplicatedStorage:WaitForChild("Dialogue")
local frame = script.Parent.Frame
local thumbnail = frame.Thumbnail
local text = frame.Dialogue
local player = thumbnail.Player

function Message(speech)
 for i = 1, #speech do
  text.Text = string.sub(speech, 1, i)
	ping:Play()
	wait()
 end
end
dialogue.OnClientEvent:Connect(function(plr, speech, id)
 player.Text = plr.Name
 thumbnail.Image = id
 Message(speech)
end)

4 comments

0

use game.Players:GetPlayers() instead and can you post the complete script

0

eyah for sure.

0

yeah*

0

also, game.Players:GetPlayers() didnt work..

1 answer

Assuming this is full script, You have wait(5) in front of random player picker. Your random player picker is alright, but after 5 seconds of a server running there is probably only one player that triggered server start so it always picks him.

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