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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 07:27 AM
How would I get a print math random(1,2) and if statement for print
this doesn't work
print(math.random(1,2)
if print == 1 then
teama = game.workspace.Bears:Clone()
teama.Parent = game.Teams
teamb = game.workspace.Packers:Clone()
else if print == 2 then
teamc = game.workspace.Broncos:Clone()
teamc.Parent = game.Teams
teamd = game.workspace.49ers:Clone()
teamd.Parent = game.Teams

I want a more "random Situation" I have 50 teams I want 2 to be chosen randomly how would I achieve this?
Report Abuse
Oozlebachr is not online. Oozlebachr
Joined: 30 Aug 2009
Total Posts: 22223
22 Sep 2013 07:29 AM
local n = math.random(2)
print(n)
if n == 1 then
teama = game.workspace.Bears:Clone()
teama.Parent = game.Teams
teamb = game.workspace.Packers:Clone()
teamb.Parent = game.Teams
else
teamc = game.workspace.Broncos:Clone()
teamc.Parent = game.Teams
teamd = game.workspace.49ers:Clone()
teamd.Parent = game.Teams
end
Report Abuse
Oozlebachr is not online. Oozlebachr
Joined: 30 Aug 2009
Total Posts: 22223
22 Sep 2013 07:30 AM
for the 50 teams thing i'd just index a big table of all of the teams then use math.random() to choose two random children of the table
Report Abuse
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 07:30 AM
Could anyone make it more random cause I have like 50 teams
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 07:31 AM
local print = math.random(1,2)
if print == 1 then
--What you want to happen here
elseif print == 2 then
--what you want to happen here if not print == 1
end

Print is a function, not a variable. You did not define print.
Report Abuse
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 07:32 AM
Idk how to make an index table
Report Abuse
08C is not online. 08C
Joined: 26 Jan 2013
Total Posts: 847
22 Sep 2013 07:33 AM
[ Content Deleted ]
Report Abuse
08C is not online. 08C
Joined: 26 Jan 2013
Total Posts: 847
22 Sep 2013 07:34 AM
[ Content Deleted ]
Report Abuse
Oozlebachr is not online. Oozlebachr
Joined: 30 Aug 2009
Total Posts: 22223
22 Sep 2013 07:35 AM
local teams = {}

for _,v in ipairs(workspace.Teams:GetChildren()) do
table.insert(teams,v)
end

local n = math.random(#teams)
local teama = teams[n]
local newteama = teama:clone()
newteama.Parent = game.Teams
table.remove(teams,n)

local newteamb = teams[math.random(#teams)]:clone()
newteamb.Parent = game.Teams

print("chose teams "..newteama.Name.." and "..newteamb.Name)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
22 Sep 2013 07:37 AM
local teams = {}

for _,v in ipairs(workspace.Teams:GetChildren()) do
table.insert(teams,v)
end

Y u no just
local teams = workspace.Teams:GetChildren()
Middle men suck.
Report Abuse
Oozlebachr is not online. Oozlebachr
Joined: 30 Aug 2009
Total Posts: 22223
22 Sep 2013 07:38 AM
stick your teams in a model named Teams in workspace
really not the cleanest way to go about doing this but tried to make it simple for you :p
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
22 Sep 2013 07:38 AM
ikr.
Report Abuse
Oozlebachr is not online. Oozlebachr
Joined: 30 Aug 2009
Total Posts: 22223
22 Sep 2013 07:39 AM
"Y u no just
local teams = workspace.Teams:GetChildren()"

yeah that wasnt the best idea on my part, used to making stuff where you build and remove the table as you go so table.insert and table.remove are like burned into my brain :p
Report Abuse
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 07:49 AM
Its says on line 9 foe oozle that clone is nil
Report Abuse
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 07:51 AM
Workspace.Script:9: attempt to call method 'Clone' (a nil value)
07:51:13.178 - Script 'Workspace.Script', Line 9
07:51:13.180 - stack end
Report Abuse
king4000000 is not online. king4000000
Joined: 22 Oct 2011
Total Posts: 397
22 Sep 2013 08:48 AM
help
Report Abuse
Thedestroyer5001 is not online. Thedestroyer5001
Joined: 31 May 2013
Total Posts: 25
22 Sep 2013 09:09 AM
1.
math.randomseed(tick())
int=((math.random(1,2)*100)
if int = (1*100) then
bla
de bla bla
else if
if int = (2*100) then
bla
de bla bla
end
doesn't get randomer than this kid
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