of     1   

iiAviatorNine
#184243503Wednesday, February 24, 2016 12:20 PM GMT

Anyone know why this executes once, but messes up after executing "--do stuff". I think it's a logical error but it's really bugging me that I can't find it e.e a = {1, 2, 3} b = {2, 3, 4} c = {3, 1} d = {4, 2} table1 = a function whichTable(in) local listOfNumbers = {1, 2, 3, 4} local listOfLetters = {a, b, c, d} local x = 1 local b = true while b == true do if in == listOfNumbers[x] then out = listOfLetters[x] b = false else x = x + 1 end end return out end while true do number = table1[math.random(2, #table1)] --do stuff table1 = nil table1 = whichTable(number) wait(0.1) end ~CrayBray
iiAviatorNine
#184243519Wednesday, February 24, 2016 12:20 PM GMT

Oops, as this is a simplified version overlooked the fact that there's two b's, one being a variable one being a table e.e Ignore that mistake in the above code. ~CrayBray
iiAviatorNine
#184243531Wednesday, February 24, 2016 12:21 PM GMT

I can pay in rbx if someone wants some easy cash. ~CrayBray
Inteque
#184243643Wednesday, February 24, 2016 12:27 PM GMT

since table1 equals nil, it doesn't exist anymore.
iiAviatorNine
#184243669Wednesday, February 24, 2016 12:28 PM GMT

Got it working magically. Might've been something to do with math.random(2, #table) Can you not do this? 0.o ~CrayBray
iiAviatorNine
#184243687Wednesday, February 24, 2016 12:28 PM GMT

whichTable() is supposed to reassign table1, of which I believe it does. ~CrayBray
Inteque
#184243688Wednesday, February 24, 2016 12:28 PM GMT

that also works
iiAviatorNine
#184243701Wednesday, February 24, 2016 12:29 PM GMT

Yeah, so I'm just sitting here confused rn. At least it works. ~CrayBray
iiAviatorNine
#184243745Wednesday, February 24, 2016 12:31 PM GMT

If anyone wants the robux tell me why the following code works but the code in the original post does not 0.o pOne = {game.Workspace.p2.Position} pTwo = {game.Workspace.p3.Position, game.Workspace.p4.Position} pThree = {game.Workspace.p1.Position} pFour = {game.Workspace.p2.Position} cPoint = pOne function whatPoint(inPoint) local PointLoc = {game.Workspace.p1.Position, game.Workspace.p2.Position, game.Workspace.p3.Position, game.Workspace.p4.Position} local PointName = {pOne, pTwo, pThree, pFour} local x = 1 local b = true while b == true do if inPoint == PointLoc[x] then outPoint = PointName[x] b = false else x = x + 1 end wait(0.1) end return outPoint end while true do nPoint = cPoint[math.random(1, #cPoint)] path = game:GetService("PathfindingService"):ComputeRawPathAsync(cPoint[1], nPoint, 200) local points = path:GetPointCoordinates() for i = 1,#points do game.Workspace.Farmer.Humanoid:MoveTo(points[i]) game.Workspace.Farmer.Humanoid.MoveToFinished:wait() end cPoint = nil cPoint = whatPoint(nPoint) wait(0.1) end ~CrayBray
Inteque
#184243760Wednesday, February 24, 2016 12:32 PM GMT

I see what you did wrong. You made math.random also execute table1, but since you did number = table1[math.random(2, #table1)] you made it execute table1 twice. if you still don't get it, you already wrote "table1" in number, executing it twice when you wrote table1 = whichTable(number), number already contains table1 in it, so it just comes back with an error
Inteque
#184243789Wednesday, February 24, 2016 12:34 PM GMT

second code doesn't contain math.random. also, i noticed something in the 1st code, math.random doesn't actually work with tables lol.
Inteque
#184243825Wednesday, February 24, 2016 12:35 PM GMT

math.randomseed(tick() is what you forgot to put first in the first code. if you just do math.random, it assumes you are printing it
OzzyFin
#184243872Wednesday, February 24, 2016 12:37 PM GMT

"math.randomseed(tick() is what you forgot to put first in the first code. if you just do math.random, it assumes you are printing it" no definitely a no
iiAviatorNine
#184243878Wednesday, February 24, 2016 12:37 PM GMT

Hmmm.... Ok I guess. Gonna have to do some research into that 0.o ~CrayBray

    of     1