|
| 17 Jul 2011 04:38 PM |
the problem with this script is that the delay makes the varible change before it is used. I can't figure out a solution. Some help? it is not as long as it looks just the same thing repeated for models. and also none of the varibles are nil
function modelscanner(model) local modelchildren = model:GetChildren() for i = 1,#modelchildren, 2 do a = a + 1 print(a) if modelchildren[i].className == "Part" then g3 = true position = modelchildren[i].Position elseif modelchildren[i].className == "Model" then modelscanner(modelchildren[i]) end if i+1 <= #modelchildren then nn2 = true if modelchildren[i+1].className == "Part" then g4 = true position2 = modelchildren[i+1].Position elseif modelchildren[i].className == "Model" then modelscanner(modelchildren[i]) end end wait() if g3 == true then g3 = false if (position - modelchildren[i].Position).magnitude > sencitive then s = s + 1 Parts[s] = modelchildren[i] end end if g4 == true and nn2 ~= false then g4 = false if (position2 - modelchildren[i+1].Position).magnitude > sencitive then s = s + 1 Parts[s] = modelchildren[i+1] end end nn2 = false end end
local children = game.Workspace:GetChildren() for i = 1,#children, 2 do a = a + 1 print(a) delay(0,function() if children[i].className == "Part" then g = true position = children[i].Position g = true elseif children[i].className == "Model" then modelscanner(children[i]) end if i+1 <= #children then nn = true if children[i+1].className == "Part" then g2 = true position2 = children[i+1].Position elseif children[i].className == "Model" then modelscanner(children[i]) end end wait() if g == true then g = false if (position - children[i].Position).magnitude > sencitive then s = s + 1 Parts[s] = children[i] end end if g2 == true and nn ~= false then g2 = false if (position2 - children[i+1].Position).magnitude > sencitive then s = s + 1 Parts[s] = children[i+1] end end end) pause = pause + 1 if pause == 5 then wait() pause = 0 end nn = false end |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2011 04:46 PM |
| Well rather then have us figure out what the variable is and what importance it holds to the script why don't you elaborate more or point out where it went wrong? Try making a comment next to the script with a -- |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2011 04:55 PM |
example: a = 0 position = 0 for i = 1,50 do delay(0,function() a = a + 1 position = a wait() print(position)--will never print 1 even if a = 1 at one point. end) end
what i need help with is to make position change every time so it will print 1 as shone above.
function modelscanner(model) local modelchildren = model:GetChildren() for i = 1,#modelchildren, 2 do a = a + 1 print(a) if modelchildren[i].className == "Part" then g3 = true position = modelchildren[i].Position -- varible "position" elseif modelchildren[i].className == "Model" then modelscanner(modelchildren[i]) end if i+1 <= #modelchildren then nn2 = true if modelchildren[i+1].className == "Part" then g4 = true position2 = modelchildren[i+1].Position--varible "position2" elseif modelchildren[i].className == "Model" then modelscanner(modelchildren[i]) end end wait() if g3 == true then g3 = false if (position - modelchildren[i].Position).magnitude > sencitive then s = s + 1 Parts[s] = modelchildren[i] end end if g4 == true and nn2 ~= false then g4 = false if (position2 - modelchildren[i+1].Position).magnitude > sencitive then s = s + 1 Parts[s] = modelchildren[i+1] end end nn2 = false end end
local children = game.Workspace:GetChildren() for i = 1,#children, 2 do a = a + 1 print(a) delay(0,function() if children[i].className == "Part" then g = true position = children[i].Position -- varible "position" g = true elseif children[i].className == "Model" then modelscanner(children[i]) end if i+1 <= #children then nn = true if children[i+1].className == "Part" then g2 = true position2 = children[i+1].Position -- varible "position2" elseif children[i].className == "Model" then modelscanner(children[i]) end end wait() if g == true then g = false if (position - children[i].Position).magnitude > sencitive then s = s + 1 Parts[s] = children[i] end end if g2 == true and nn ~= false then g2 = false if (position2 - children[i+1].Position).magnitude > sencitive then s = s + 1 Parts[s] = children[i+1] end end end) pause = pause + 1 if pause == 5 then wait() pause = 0 end nn = false end |
|
|
| Report Abuse |
|
|
| |
|