generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do you make a random character or number

Previous Thread :: Next Thread 
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 01:55 PM
I'm trying to make a script that generates a random code that would be unique for each player.

~مانند یک گانگستر واقعی~
Report Abuse
BaconSoap is not online. BaconSoap
Joined: 12 Sep 2010
Total Posts: 1882
09 Jun 2014 01:57 PM
repeat a math.random on a table of a - z and 1 - 9 a number of times depending on how many characters you want
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
09 Jun 2014 01:59 PM
Wouldn't even need that.

Just get the plrID of the plr and use that.

Property of no one, [insert forever alone meme here]
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:02 PM
Never mind the number part, I looked it up and I can just use this
math.random(1000,9999)

But I need to get three letters at the beginning of it. How would you do the table?

~مانند یک گانگستر واقعی~
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
09 Jun 2014 02:03 PM
My way is easier ;-;

Property of no one, [insert forever alone meme here]
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:05 PM
I don't need just numbers, I need letters.

~مانند یک گانگستر واقعی~
Report Abuse
superbobman is not online. superbobman
Joined: 29 Nov 2008
Total Posts: 939
09 Jun 2014 02:07 PM
Using the player ID would insure that no one has the same ID.
Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
09 Jun 2014 02:07 PM
make a table with all letters(a-z)
then do 3 times math.random(1,#tablename) and you got your 3 letters
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:09 PM
I'm sorry I wasn't clear because I didn't really think it was necessary to explain it all and if my question was answered instead of getting suggestions, I wouldn't have needed to type all of this.
It's a script that generates a license plate number when a car is spawned and has nothing to do with players. Come to think of it, I probably should have just said that to begin with.

~مانند یک گانگستر واقعی~
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
09 Jun 2014 02:10 PM

1 = a
2 = b
Ect

Math.random (1,26)
Random charactor

Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
09 Jun 2014 02:10 PM
We gave you everything you need for making your random numbers and letters
if you still can't figure out how to do it then i'll post the code you'll need.
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:11 PM
Plate.Value = "ABC ".. math.random(1000,9999)

That's what I have right now. How would I make ABC have random letters instead of just ABC.

~مانند یک گانگستر واقعی~
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:11 PM
Forget it then, I'll just figure it out myself.

~مانند یک گانگستر واقعی~
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
09 Jun 2014 02:16 PM
Just use the Player ID dammit

alpha = {"a","b","c","d","e","f","g"} -- etc

Plate.Name = math.random(1,#alpha) .. math.random(1,#alpha) .. math.random(1,#alpha) .. --insert plr id code here i forgot it ;-;

Property of no one, [insert forever alone meme here]
Report Abuse
EcIiptic is not online. EcIiptic
Joined: 12 Aug 2009
Total Posts: 13737
09 Jun 2014 02:18 PM
@ZIr

Player.userId

#Piano
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:21 PM
omg there are no players involved in this script

~مانند یک گانگستر واقعی~
Report Abuse
AlgyLacey is not online. AlgyLacey
Joined: 14 Jun 2013
Total Posts: 3736
09 Jun 2014 02:27 PM
Ok, Here's what you do:

L1 = math.random (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
L2 = math.random (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
L3 = math.random (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
L4 = math.random (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
N1 = math.random (1,2,3,4,5,6,7,8,9)
N1 = math.random (1,2,3,4,5,6,7,8,9)
N1 = math.random (1,2,3,4,5,6,7,8,9)

TextBox.Text = ""..L1..L2..L3..L4..N1..N2..N3..""

BINGO, you have a numberplate with four letters and three numbers, swap around how you like!

-Algy
Report Abuse
AlgyLacey is not online. AlgyLacey
Joined: 14 Jun 2013
Total Posts: 3736
09 Jun 2014 02:28 PM
@Eclip, PlayerIDs are just numbers, he said he wants numbers and letters.
Report Abuse
AlgyLacey is not online. AlgyLacey
Joined: 14 Jun 2013
Total Posts: 3736
09 Jun 2014 02:33 PM
Actually, I'll give a better, tested and working version in a minute.
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 02:36 PM
I've got a working one now so forget this thread.

~مانند یک گانگستر واقعی~
Report Abuse
ZirutoHellfire is not online. ZirutoHellfire
Joined: 16 Aug 2012
Total Posts: 4647
09 Jun 2014 02:36 PM
why use letters when you can use numbers and player id's which is way easier and more efficient

game.Players.PlayerAdded:connect(function(p)
Plater.Value = p.userid
end)

Property of no one, [insert forever alone meme here]
Report Abuse
RealPersa is not online. RealPersa
Joined: 21 Dec 2012
Total Posts: 7124
09 Jun 2014 03:18 PM
I am making a license plate. What kind of license plate has only numbers in it? And I have said multiple times that there is no player anywhere in this script. Even if I wanted to put the PlayerID, there is no player to get it from.

~مانند یک گانگستر واقعی~
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
09 Jun 2014 03:32 PM
this could probably be shortened and I know you already got it but here is another one:

local min = math.random(7, 10)
local plate = ""
for x = 1, min do
local random = math.random(1, 9)
local upper = string.char(math.random(65, 90))
local lower = string.char(math.random(97, 122))

local choice = math.random(1, 3)
if choice == 1 then
plate = plate .. random
elseif choice == 2 then
plate = plate .. upper
elseif choice == 3 then
plate = plate .. lower
end
end

print(plate)
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
09 Jun 2014 03:34 PM
local min = math.random(7, 10)
local plate = ""
for x = 1, min do
local random = math.random(1, 9)
local upper = string.char(math.random(65, 90))

local choice = math.random(1, 2)
if choice == 1 then
plate = plate .. random
elseif choice == 2 then
plate = plate .. upper
end
end

print(plate)

might not make sense to have lowercase
Report Abuse
TexasOreo is not online. TexasOreo
Joined: 08 Apr 2014
Total Posts: 25
09 Jun 2014 03:41 PM
Jimmy that can be shortened a lot:

local plate = ""
for x = 1, math.random(7, 10) do
local random = math.random(1, 9)
local upper = string.char(math.random(65, 90))
if math.random(1, 2) > 1 then plate = plate .. upper else plate = plate .. random end
end

print(plate)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image