Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a script that is able to get a random players avatar and name? (Camping Game) [closed]

Asked by 5 years ago

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 made a GUI that has the following included: SurfaceGUI, textlabel, another textlabel, frame, ImageLabel.

One of the text label should be for displaying the user's name, the other one for the dialogue. The ImageLabel will be for showing the random player's avatar.

Can this be done, if so, please help. Thanks!

This is for a camping game, on roblox.

0
Can you give an example of your script? GalTheGod 22 — 5y
0
Please post your script. sngnn 274 — 5y
0
I dont have the scripts. TrueFalses -15 — 5y

Closed as Not Constructive by cmgtotalyawesome, royaltoe, hiimgoodpack, ForeverBrown, maumaumaumaumaumua, and User#5423

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 5 years ago

You can add in a script somewhere that has a function that runs when the player joined. That function will create a StringValue. The name of the StringValue will be 1 for the first player that joined, 2 for the second that joined, etc. The Value of the StringValue will be the joined player's name. That StringValue's parent will be the Workspace.

If you want to randomly choose a player to say a dialog you can now use the math.random option, cuz math.random only uses numbers , but you already named the StringValues in workspace with numbers. You can do this to randomly choose a player to say a dialog:

local chosenPlayerValue = math.random(1,#game.Players:GetChildren)
local chosenPlayer =  game.Workspace:WaitForChild(chosenPlayer)
local playerName = chosenPlayer.Name
> ADD WHATEVER YOU WANNA DO

Hope this helped!

0
I am not really much of a scripter, so if you can show in the scripts everything that wants to be done, you will be a legend, and if no, I will try and manage with this information. I understand this website is designed to help people's scripts and not to request. I got some of what you said though. Thanks! TrueFalses -15 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago
local rng=math.random(1,#game.Players:GetChildren())
local pl;
local gui=your gui here
for i,v in pairs(game.Players:GetChildren()) do
    if i==rng then
        pl=v
    end
end

gui.TextLabel.Text=pl.Name
gui.ImageLabel.Image=https://www.roblox.com/bust-thumbnail/image?userId=..pl.UserId..&width=420&height=420&format=png

This should work, not tested it. If it does: please accept this answer. Thank you!

0
Hi, thanks! Do you know where this script is located? TrueFalses -15 — 5y
0
in a local script somewhere inside your gui royaltoe 5144 — 5y
0
Yes sorry, this is located inside either game.StarterPlayer.StarterPlayerScripts or StarterGui! arondevs 65 — 5y