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: Why does this not work???

Previous Thread :: Next Thread 
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
04 Jan 2012 08:30 PM
script.Parent.ClickDetector.MouseClick:connect(function(Playah)
if Playah.Name == script.Parent.Parent.Parent.OwnerName.Value and
script.Parent.Parent.Parent.Cubes.Cube1:findFirstChild("Mesh") == nil and
script.Parent.Parent.Parent.Cubes.Cube400:findFirstChild("Mesh") == nil then
wait(3)
for i = 0, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.1)
end
elseif script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and
script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then
wait(3)
for i = 0, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.1)
end
end
end)

errors:

Workspace.Art Studio.Factory.Buttons.Finish Button.Finish:16: attempt to index a nil value
Script "Workspace.Art Studio.Factory.Buttons.Finish Button.Finish", Line 16
stack end
Report Abuse
skipperguy12 is not online. skipperguy12
Joined: 09 Oct 2009
Total Posts: 955
04 Jan 2012 08:35 PM
("Cube"..i)

Something be wrong here...
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
04 Jan 2012 08:37 PM
The part where it adds the mesh to all 400 blocks works, but not the part where it removes them.
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
04 Jan 2012 08:45 PM
You don't have a Cube0?

You have
Cube1:FindFirstChild()
and
Cube400:FindFirstChild()

But your loop is from 0 to 400
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
05 Jan 2012 06:21 AM
So this is what i would need?

script.Parent.ClickDetector.MouseClick:connect(function(Playah)
if Playah.Name == script.Parent.Parent.Parent.OwnerName.Value and
script.Parent.Parent.Parent.Cubes.Cube1:findFirstChild("Mesh") == nil and
script.Parent.Parent.Parent.Cubes.Cube400:findFirstChild("Mesh") == nil then
wait(3)
for i = 1, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.1)
end
elseif script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and
script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then
wait(3)
for i = 1, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.1)
end
end
end)

Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
05 Jan 2012 09:01 AM
script.Parent.ClickDetector.MouseClick:connect(function(Playah)
if Playah.Name == script.Parent.Parent.Parent.OwnerName.Value and
script.Parent.Parent.Parent.Cubes.Cube1:findFirstChild("Mesh") == nil and
script.Parent.Parent.Parent.Cubes.Cube400:findFirstChild("Mesh") == nil then
wait(3)
for i = 1, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.1)
elseif script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and
script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then
wait(3)
for i = 1, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.1)
end
end
end
end)
Report Abuse
Blues714 is not online. Blues714
Joined: 23 Dec 2008
Total Posts: 6507
05 Jan 2012 09:48 AM
script.Parent.ClickDetector.MouseClick:connect(function(Playah)
if Player.Name == script.Parent.Parent.Parent.OwnerName.Value and
script.Parent.Parent.Parent.Cubes.Cube0:findFirstChild("Mesh") == nil and
script.Parent.Parent.Parent.Cubes.Cube400:findFirstChild("Mesh") == nil then
wait(3)
for i = 1, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.1)
else if script.Parent.Parent.Parent.Cubes.Cube0.Mesh ~= nil and
script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then
wait(3)
for i = 1, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.1)
end
end
end
end)



0 counts as a number! 0 to 400. 1 to 400 won't make it work. And, you didn't space else and if. It looked like this

(elseif) script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and

Double check what you do.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
05 Jan 2012 04:12 PM
wait so elseif needs to be else if?

I always thought you were supposed to make it one word in Lua...
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
05 Jan 2012 04:21 PM
ok, it still wont work...

Heres the script im using now...

script.Parent.ClickDetector.MouseClick:connect(function(Player)
if Player.Name == script.Parent.Parent.Parent.OwnerName.Value and
script.Parent.Parent.Parent.Cubes.Cube1:findFirstChild("Mesh") == nil and
script.Parent.Parent.Parent.Cubes.Cube400:findFirstChild("Mesh") == nil then
wait(3)
for i = 0, 400 do
m = Instance.new("BlockMesh")
m.Name = "Mesh"
m.Parent = script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i)
wait(0.1)
end
else if script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and
script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then
wait(3)
for i = 0, 400 do
script.Parent.Parent.Parent.Cubes:findFirstChild("Cube"..i).Mesh:Remove()
wait(0.1)
end
end
end
end)

And heres the errors...

Workspace.Art Studio.Factory.Buttons.Finish Button.Finish:16: attempt to index a nil value
Script "Workspace.Art Studio.Factory.Buttons.Finish Button.Finish", Line 16
stack end

Notes: I have cubes 1-400 in a modle called Cubes, each wioth the names Cube1- Cube400.
Report Abuse
Tkdriverx is not online. Tkdriverx
Joined: 27 May 2008
Total Posts: 235
05 Jan 2012 04:49 PM
There doesn't have to be a space between the else and the if, 'else if' just makes it do an else (which inverts the previous 'if' statement) then it does another 'if' statement if the 'else' is true.

And also, if you have Cube1 - Cube400, it needs to be

for i = 1, 400 do

not

for i = 0, 400 do

because it should start at 1, not 0.

You should also just do a :GetChildren() function, it will make it easier to check if there's a mesh in the brick and then add one.

~ Tkdriverx ~
Report Abuse
Tkdriverx is not online. Tkdriverx
Joined: 27 May 2008
Total Posts: 235
05 Jan 2012 04:55 PM
Also, to check if an item is inside another item, do :findFirstChild("Mesh").
This was on line 10:

else if script.Parent.Parent.Parent.Cubes.Cube1.Mesh ~= nil and script.Parent.Parent.Parent.Cubes.Cube400.Mesh ~= nil then

which should be changed to:

elseif script.Parent.Parent.Parent.Cubes:findFirstChild("Cube1"):findFirstChild("Mesh") ~= nil and script.Parent.Parent.Parent.Cubes:findFirstChild("Cube400"):findFirstChild("Mesh") ~= nil then

And it appears you put the and lines on separate lines, and they should be on the same line.

~ Tkdriverx ~
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
05 Jan 2012 05:02 PM
Didn't anyone notice the bottom?

Workspace.Art Studio....
is supposed to be

Workspace["Art Studio"].whatever.whatever
Report Abuse
Tkdriverx is not online. Tkdriverx
Joined: 27 May 2008
Total Posts: 235
05 Jan 2012 05:07 PM
@epicfail22
That's how the Output prints errors.

~ Tkdriverx ~
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
05 Jan 2012 05:07 PM
it works now, thanks soo much
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
05 Jan 2012 05:11 PM
elseif and else if are both totally different.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
05 Jan 2012 07:39 PM
@Tkdriverx

Oh woops didn't even realize it was output. I thought it was a connection line.
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