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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Conditional statement breaks code

Previous Thread :: Next Thread 
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 09:37 PM
I have a conditional statement, that if an object exists, it runs the rest of the code. If it doesn't exist, it is supposed to do nothing. It works if the object exists, but if it doesn't, it not only does nothing, but brakes the code! I've tried adding else and elseif, but that didn't fix it. What am I doing wrong?

Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
15 Jul 2013 09:39 PM
Well I could tell you for sure if you posted a code snippet
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 09:40 PM
--code
if script.Parent.Parent:FindFirstChild("Ready1", true) then
--code
end
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
15 Jul 2013 09:44 PM
If the script is parented to nil then this would error
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 09:45 PM
It isn't.
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
15 Jul 2013 09:47 PM
What does the output say?
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 09:48 PM
Nothing.
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
15 Jul 2013 09:53 PM
Did the code you posted work?
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 09:55 PM
...No? I thought I stated what my problem was... It works if the object exists, but brakes the code if it doesn't.
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
15 Jul 2013 09:58 PM
Set recursive to false and try it
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 10:01 PM
That didn't work, but just out of curiosity, why did you want me to try that? The wiki states quite plainly that using setting the recursive to false will not find the object.
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
15 Jul 2013 10:09 PM
It will find the object if the object is in the directory. I'm going to need to see more of your script to figure it out
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 10:15 PM
Full script:



BlueSpawn = {game.Workspace.SBSpawns.SBSpawn1, game.Workspace.SBSpawns.SBSpawn2, game.Workspace.SBSpawns.SBSpawn3, game.Workspace.SBSpawns.SBSpawn4, game.Workspace.SBSpawns.SBSpawn5}
RedSpawn = {game.Workspace.SRSpawns.SRSpawn1, game.Workspace.SRSpawns.SRSpawn2, game.Workspace.SRSpawns.SRSpawn3, game.Workspace.SRSpawns.SRSpawn4, game.Workspace.SRSpawns.SRSpawn5}
Player = game.Players.LocalPlayer
deb = false
script.Parent.MouseButton1Down:connect(function()
if deb == true then return end
deb = true
if script.Parent.Parent:FindFirstChild("Ready1", true) then
--[[if script.Parent.Parent:FindFirstChild("Ready2", true) then
if script.Parent.Parent:FindFirstChild("Ready3", true) then
if script.Parent.Parent:FindFirstChild("Ready4", true) then
if script.Parent.Parent:FindFirstChild("Ready5", true) then
if script.Parent.Parent:FindFirstChild("Ready6", true) then--]]
p = Player.Backpack.Primary:GetChildren()
for i, v in ipairs (p) do
local vc = v
vc.Parent = Player.Backpack
if p then
game.Debris:AddItem(Player.Backpack.Primary, 0)
s = Player.Backpack.Secondary:GetChildren()
for i, v in ipairs (s) do
local v2 = v
v2.Parent = Player.Backpack
if s then
game.Debris:AddItem(Player.Backpack.Secondary, 0)
t = Player.Backpack.Tetiary:GetChildren()
for i, v in ipairs (t) do
local v3 = v
v3.Parent = Player.Backpack
if t then
game.Debris:AddItem(Player.Backpack.Tetiary, 0)
e1 = Player.Backpack:FindFirstChild("1st Explosive"):GetChildren()
for i, v in ipairs (e1) do
local v4 = v
v4.Parent = Player.Backpack
if e1 then
game.Debris:AddItem(Player.Backpack:FindFirstChild("1st Explosive"), 0)
e2 = Player.Backpack:FindFirstChild("2nd Explosive"):GetChildren()
for i, v in ipairs (e2) do
local v5 = v
v5.Parent = Player.Backpack
if e2 then
game.Debris:AddItem(Player.Backpack:FindFirstChild("2nd Explosive"), 0)
l = Player.Backpack:FindFirstChild("Light"):GetChildren()
for i, v in ipairs (l) do
local v6 = v
v6.Parent = Player.Backpack
if l then
game.Debris:AddItem(Player.Backpack:FindFirstChild("Light"), 0)
if Player.TeamColor == BrickColor.new ("Teal") then
Player.Character.Torso.CFrame = CFrame.new(BlueSpawn[math.random(1,#BlueSpawn)].Position)
game.Debris:AddItem(script.Parent.Parent.Parent, 0)
elseif Player.TeamColor == BrickColor.new ("Bright red") then
Player.Character.Torso.CFrame = CFrame.new(RedSpawn[math.random(1,#RedSpawn)].Position)
game.Debris:AddItem(script.Parent.Parent.Parent, 0)
deb = false
--[[end
end
end
end
end-]]
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end)
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 10:30 PM
Bump
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
15 Jul 2013 10:50 PM
Bump.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
15 Jul 2013 11:16 PM
Im basicly bumping this for you but...


if brick = nil then return false
else return true

Maybe that might help?
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 12:26 AM
Nope, that didn't work, sadly.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 12:53 AM
Bump
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 12:23 PM
Bump.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 12:54 PM
Bump..
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
16 Jul 2013 01:14 PM
Killer,

u r going to have to de-bug it yourself. Put a print statement at every-other line to follow what u r actually doing.........

print(deb)
if deb == true then return end
deb = true
print(script.Parent.Parent, script.Parent.Parent:FindFirstChild("Ready1", true) )
if script.Parent.Parent:FindFirstChild("Ready1", true) then
--[[if script.Parent.Parent:FindFirstChild("Ready2", true) then

and so on, 4 the whole script.......
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 01:15 PM
The rest of the script works, it only breaks when I put in the if statement. I was wondering why this was.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
16 Jul 2013 04:37 PM
I fixed it. I forgot to set the deb back to false on the else return end. Lol fail. Well, thanks anyways guys!
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