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
 

Re: Know the problem,Can't figure out a solition.

Previous Thread :: Next Thread 
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
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
Eman1234567 is not online. Eman1234567
Joined: 19 Dec 2008
Total Posts: 6544
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
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
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
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
17 Jul 2011 06:02 PM
Bump
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