|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Sep 2013 07:30 AM |
| Could anyone make it more random cause I have like 50 teams |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 22 Sep 2013 07:32 AM |
| Idk how to make an index table |
|
|
| Report Abuse |
|
|
08C
|
  |
| Joined: 26 Jan 2013 |
| Total Posts: 847 |
|
| |
|
08C
|
  |
| Joined: 26 Jan 2013 |
| Total Posts: 847 |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 22 Sep 2013 07:49 AM |
| Its says on line 9 foe oozle that clone is nil |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|