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: If statement help.

Previous Thread :: Next Thread 
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
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
kingmod123 is not online. kingmod123
Joined: 16 May 2009
Total Posts: 699
25 Nov 2011 03:43 PM
What's Plyr?
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
25 Nov 2011 03:44 PM
Its a string to the Player
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
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 is not online. 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
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
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 is not online. 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
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
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 is not online. 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
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
25 Nov 2011 05:07 PM
Thx :3
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