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: Jesus Christ, Lua

Previous Thread :: Next Thread 
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 06:38 AM
> if player.Character.Torso ~= nil then
> Torso is not a valid member of model

wat
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
03 Sep 2013 06:39 AM
if player.Character:FindFirstChild("Torso") ~= nil
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
03 Sep 2013 06:43 AM
"if player.Character.Torso ~= nil then"
"if"
Lua: K is an if statement
"player.Character.Torso"
Lua: Dafudge is that? Dunno, Just going to stop here.


"if player.Character:FindFirstChild("Torso") ~= nil"
"if"
Lua: K is an if statement
"player.Character:FindFirstChild("Torso")"
Lua:K didn`t find it so it`s nil
"~= nil"
Lua:K it`s nil, Gonna look for an end now
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
03 Sep 2013 06:48 AM
Oh God, why would you '~= nil' on a Boolean return?

if (player.Character:findFIrstChild('Torso')) then
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Sep 2013 08:58 AM
Blame yourself before you blame the computer
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
03 Sep 2013 09:00 AM
It didn't exist. duh. + what cm32 said because he likes to be called cm32


TRIOXIDE TRIOXIDE TRIOXIDE TRIOXIDE TRIOXIDE TRIOXIDE
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 11:01 AM
But it works on other things? The only reason I did it like that instead of using FindFirstChild() is because what if their character is gone? Whateva I'll just do it the annoying inefficient way.
Report Abuse
superswordfish is not online. superswordfish
Joined: 14 Jun 2013
Total Posts: 1336
03 Sep 2013 11:04 AM
:findFirstChild is always more efficient for checking stuff. If you want to get even more efficient, do it like this :D.

if player:findFirstChild("Character"):findFirstChild("Torso") then

LOL!! This is more efficient in case the character is gone as you said.
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 11:05 AM
Isn't character a property of Player and not a child though?
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Sep 2013 11:51 AM
Yes, but Torso is not a property. You're trying to access 'Torso' in the Character, and if Torso doesn't exist, then you're gonna get an error since you're trying to reference something that doesn't exist.

if (player.Character:FindFirstChild("Torso")) then
...
end
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 01:48 PM
Yeah, I know what I have to do, it's just ugly. I want to check if all three of them are not nil in one clean line but that's not gonna happen so whateva.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Sep 2013 02:00 PM
if (player.Character and player.Character:FindFirstChild("Torso")) then ...
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 02:04 PM
Right, cuz player.Character is a property; but I think I'll just check for Torso, I've had no character problems, it's just Torsos are disappearing for some reason.
Report Abuse
Ri1es is not online. Ri1es
Joined: 19 Mar 2011
Total Posts: 108
03 Sep 2013 02:35 PM
The reason you have had no problem with .Character is because it is a property of the Player object, which equals the player's character.

E.g.
"if player.Character ~= nil then" would work because Character is not a child of the player but a property.
However
"player:FindFirstChild("Character")" would return nil because there is no child called Character in the Player object, but it would return an object if there was a child with the name of "Character".

-Ri1es
Report Abuse
Ri1es is not online. Ri1es
Joined: 19 Mar 2011
Total Posts: 108
03 Sep 2013 02:39 PM
Also Absurdism,

http://wiki.roblox.com/index.php/API:Instance/FindFirstChild

:FindFirstChild() does not have a Boolean return, it has an Instance return.

-Ri1es
Report Abuse
janthran2 is not online. janthran2
Joined: 12 Jun 2009
Total Posts: 84
03 Sep 2013 02:44 PM
Well if you knew how to script you wouldn't have a problem
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 03:28 PM
I know how to script, and I don't have a problem... I was questioning syntax that really shouldn't do what it is doing. I know that Player.Character is a property, which means it can be nil, and I know that you can't use FindFirstChild("Character").
Report Abuse
janthran2 is not online. janthran2
Joined: 12 Jun 2009
Total Posts: 84
03 Sep 2013 03:33 PM
you're just plain wrong
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
03 Sep 2013 03:34 PM
why use:
if player.Character:FindFirstChild("Torso") ~= nil

I like this more:
if player.Character:FindFirstChild("Torso") then
Report Abuse
Brycemlns is not online. Brycemlns
Joined: 28 Jan 2008
Total Posts: 216
03 Sep 2013 03:52 PM
I was stuck on this the other day as well OP, you're not alone.
Report Abuse
janthran2 is not online. janthran2
Joined: 12 Jun 2009
Total Posts: 84
03 Sep 2013 03:57 PM
You tried to reference something that doesn't exist
that's stupid
Report Abuse
Nikilis is not online. Nikilis
Joined: 25 Dec 2008
Total Posts: 949
03 Sep 2013 04:58 PM
@janthran2

I wasn't plain wrong at all; I was right.

player.Character.Torso ~= nil should honestly check if player, Character, and Torso are not nil. It should check if the entire path is not nil. If player.Character.Torso does not lead to anything, it just return as false.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
03 Sep 2013 04:59 PM
No, it reads you assuming "Torso" is part of the character before '~= nil', that's why you use FindFirstChild().
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
03 Sep 2013 05:01 PM
"player.Character.Torso ~= nil should honestly check if player, Character, and Torso are not nil. It should check if the entire path is not nil. If player.Character.Torso does not lead to anything, it just return as false."

That makes no sense. Why would it if you can do it manually anyway.
If you refer to an object in a table, why should it automatically assume the table the object is in wouldnt exist? You refer to it, you need to be sure, not Lua.
Report Abuse
mylifeis2cooldlol is not online. mylifeis2cooldlol
Joined: 08 Mar 2011
Total Posts: 874
03 Sep 2013 05:03 PM
Just use a pcall or a ypcall and call it good without the if for the character torso
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