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 » Scripters
Home Search
 

Chose Player Twice In Table

Previous Thread :: Next Thread 
iiNemo is online. iiNemo
Joined: 22 Jul 2013
Total Posts: 2380
31 Mar 2017 11:06 PM
So, if I choose something from a table randomly RanDText[math.random(#RanDText)]
I don't want it too chose it again twice in a row. How would I make it so it doesn't repeat the same object in a table twice in a row?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
31 Mar 2017 11:11 PM
local p1 = table.remove(tab,math.random(1,#tab)) local p2 = ##################################### ############
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 Mar 2017 11:12 PM
try this

local original = DATA
local random = {}
for i = 1, #original do
local key = math.random( #original )
random[ #random + 1 ] = original[ key ]
table.remove( original, key )
end
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
31 Mar 2017 11:12 PM
local player1 = table.remove(tab,math.random(1,#tab))
local player2 = table.remove(tab,math.random(1,#tab))
print(player1,player2)


Report Abuse
iiNemo is online. iiNemo
Joined: 22 Jul 2013
Total Posts: 2380
31 Mar 2017 11:17 PM
local RanDText = {'Join Build Guild For Special Power Ups & Bonus Cash!', 'Any Questions, Concerns or Bugs PM iiNemo!', 'Please Be Sure To Check Out The Store!'} while wait() do local s = RanDText[math.random(#RanDText)] for #### ## ## ################## = s:sub(1,i) wait(0.1) end wait(5) for i = ## ## ## ################## = s:sub(1,-i) wait(0.1) end end In this case how would I make it so it doesn't do the same text twice?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 Mar 2017 11:18 PM
local original = DATA
local random = {}
for i = 1, #original do
random[ #random + 1 ] = table.remove( original, math.random( #original ) )
end

just use this and set data to whatever you want
random will be a randomized table
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 Mar 2017 11:20 PM
and in case your laziness overcomes you

local _r = table.remove
local function shuffle( tbl )
local random = {}
for i = 1, #original do
random[ #random + 1 ] = _r( original, math.random( #original ) )
end
return random
end

example use:

print( shuffle( {1, 2, 3, 4} ) )
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 Mar 2017 11:20 PM
local _r = table.remove
local function shuffle( tbl )
local random = {}
for i = 1, #tbl do
random[ #random + 1 ] = _r( tbl, math.random( #tbl ) )
end
return random
end

my bad i fixed it
Report Abuse
iiNemo is online. iiNemo
Joined: 22 Jul 2013
Total Posts: 2380
31 Mar 2017 11:36 PM
I have a script where it add's text slowly then removes it slowly, how would I add that too it?
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 Mar 2017 11:36 PM
shuffle the text table and then pick a text to display? idk what you want
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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