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 |
|
|
|
| 15 Jul 2013 09:39 PM |
| Well I could tell you for sure if you posted a code snippet |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 15 Jul 2013 09:44 PM |
| If the script is parented to nil then this would error |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
| |
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
Raphael7
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 2479 |
|
|
| 15 Jul 2013 09:53 PM |
| Did the code you posted work? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 15 Jul 2013 09:58 PM |
| Set recursive to false and try it |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
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
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 16 Jul 2013 12:26 AM |
| Nope, that didn't work, sadly. |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|