|
| 25 Nov 2011 03:40 PM |
My if statements are umm well.. Not the best as most other things i do in scripting so.. Can someone help me here?
script.Parent.CrossView.MouseButton1Down:connect(function() if Plyr.Backpack.One ~=nil then Plyr.Backpack.One:remove() if Plyr.Backpack.Two ~=nil then Plyr.Backpack.Two:remove() if Plyr.Backpack.Nyan ~=nil then Plyr.Backpack.Nyan:remove() if Plyr.Backpack.One == nil and Plyr.Backpack.Two == nil and Plyr.Backpack.Nyan == nil then game.Lighting.One:clone().Parent = Plyr.Backpack end end end end end)
Seeing as that One is not in the Backpack for the first if statement. It wont continue.. I was thinking pcall, but well i don't know how to use it.. |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Nov 2011 03:44 PM |
| Its a string to the Player |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2011 03:44 PM |
Ooops sorry
Plyr = script.Parent.Parent.Parent OneV = game.Lighting.One TwoV = Game.Lighting.Two NyanM = game.Lighting.Nyan |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 25 Nov 2011 03:48 PM |
script.Parent.CrossView.MouseButton1Down:connect(function() if Plyr.Backpack:FindFirstChild("One") then Plyr.Backpack.One:remove() if Plyr.Backpack.Two then Plyr.Backpack.Two:remove() if Plyr.Backpack.Nyan then Plyr.Backpack.Nyan:remove() if Plyr.Backpack.One or Plyr.Backpack.Two or Plyr.Backpack.Nyan then return end game.Lighting.One:clone().Parent = Plyr.Backpack end end end end end)
I think I may have entirely broken it, but i will post it anyway... |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2011 03:53 PM |
Wait wouldn't it be
if Plyr.Backpack:FindFirstChild("One") ~= nil then Plyr.Backpack.One:remove() and so on? |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 25 Nov 2011 03:57 PM |
Well i stopped used ~= nil when i found it returns true if it is a valid member.
For instance:
if game.Workspace ~= nil then print 'Hello world!' end
if game.Workspace then print 'Hello world!' end
Would output: Hello world! Hello world! |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2011 04:49 PM |
Helped alot but now it just wont work.. No output. I'm assuming i had to wait for it to load but im not sure what else to add in
Plyr = script.Parent.Parent.Parent OneV = game.Lighting.One TwoV = Game.Lighting.Two NyanM = game.Lighting.Nyan
repeat wait() until game.Players ~= nil repeat wait() until Plyr.Backpack ~= nil
script.Parent.CrossView.MouseButton1Down:connect(function() if Plyr.Backpack:FindFirstChild("One") then Plyr.Backpack.One:remove() if Plyr.Backpack:FindFirstChild("Two") then Plyr.Backpack.One:remove() if Plyr.Backpack:FindFirstChild("Nyan") then Plyr.Backpack.One:remove() if Plyr.Backpack.One == nil and Plyr.Backpack.Two == nil and Plyr.Backpack.Nyan == nil then game.Lighting.One:clone().Parent = Plyr.Backpack end end end end end) |
|
|
| Report Abuse |
|
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 25 Nov 2011 04:57 PM |
It's the order that you put the ends.
Plyr = script.Parent.Parent.Parent OneV = game.Lighting.One TwoV = Game.Lighting.Two NyanM = game.Lighting.Nyan repeat wait() until game.Players ~= nil repeat wait() until Plyr.Backpack ~= nil script.Parent.CrossView.MouseButton1Down:connect(function() if Plyr.Backpack:FindFirstChild("One") then Plyr.Backpack.One:remove() end if Plyr.Backpack:FindFirstChild("Two") then Plyr.Backpack.One:remove() end if Plyr.Backpack:FindFirstChild("Nyan") then Plyr.Backpack.One:remove() end if Plyr.Backpack.One == nil and Plyr.Backpack.Two == nil and Plyr.Backpack.Nyan == nil then game.Lighting.One:clone().Parent = Plyr.Backpack end end)
---------- ~ pwendu46, the unicorn ~ |
|
|
| Report Abuse |
|
|
| |
|