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

How would I make a script that is able to get a random players avatar and name? (Camping Game)

I am looking for someone who is able to help me make a script that selects a random player from the player list. I also want the script to get their avatar and username. I was using a local player script but then I realized that the player would see their own avatar instead of random players.

I made a little example of the GUI design.

Link to design: http://prntscr.com/olrdta

Where it says "name" I want it to select a random player from the players list and display their avatar and name.

The black border is where the random avatar image will appear.

The name text is where the random players name will appear.

This is for roblox btw.

4 comments

0

for getting a random player you could just do game:GetService("Players"):GetPlayers()[math.random(1, #game:GetService("Players"):GetPlayers())] and for getting a player avatar use player:GetUserThumbnailAsync (wiki: https://developer.roblox.com/en-us/api-reference/function/Players/GetUserThumbnailAsync)

0

Otherwise this aint a request site

0

Thanks this is all new to me.

0

How do I make that into a script?

1 answer

✓ Accepted answer

Okay Make a RemoteEvent Call it Dialogue Put it in ReplicatedStorage And Make a Script Here's a script: l


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) Message(player, "Example Here", id)

And Heres a local script in the gui


local dialogue = game.ReplicatedStorage.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) wait() end end

dialogue.OnClientEvent:Connect(function(plr, speech, id) player.Text = plr.Name thumbnail.Image = id Message(speech) end)

1 comment

0

Just make an Frame And A thumbnail with a textlabel called Player and a textlabel Called Dialogue

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