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
 

Attempting to index a nil value?

Previous Thread :: Next Thread 
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 Jun 2014 04:09 PM
owner = tostring(game.Players:FindFirstChild(v.Parent.Name).TeamColor)

It's at this line.

At the top, owner is clearly defined.

owner = "White"

Everything works but this part:

if script.CapStatus.Value <= 0 then
owner = tostring(game.Players:FindFirstChild(v.Parent.Name).TeamColor)
end
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
12 Jun 2014 04:13 PM
Perhaps you should do

game.Players:GetPlayerFromCharacter(v.Parent).TeamColor

Not sure, but why are you using strings instead of just brickcolor? It seems unnecessary
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 Jun 2014 04:15 PM
Yeah I'm using strings. I already have it in the rest of the script, and I'm too lazy to change it all. :P
Report Abuse
AdmiralLennox is not online. AdmiralLennox
Joined: 19 Jun 2013
Total Posts: 378
12 Jun 2014 04:18 PM
Does v.Parent exist for all values of v?

Also, I'm pretty sure you don't have to use tostring. You should be able to say TeamColor.Name to get the string representation of a BrickColor.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 Jun 2014 04:18 PM
Still won't work.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 Jun 2014 04:20 PM
@Admiral, I use a check.
My script uses Region3 to check for parts.

"if v:IsA('BasePart') and v.Name == "Torso" and v.Parent:FindFirstChild('Humanoid') and game.Players:FindFirstChild(v.Parent.Name) then"

This is the check. There are no syntax errors.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
12 Jun 2014 04:27 PM
Well I guess I'll have to improvise. :3
Report Abuse
transIate is not online. transIate
Joined: 20 Jun 2013
Total Posts: 2699
12 Jun 2014 04:28 PM
owner=BrickColor.new'White'.Color;

lol.
Report Abuse
AdmiralLennox is not online. AdmiralLennox
Joined: 19 Jun 2013
Total Posts: 378
12 Jun 2014 04:30 PM
If v.Parent is a character, then as Citrelthkarr said you should use the GetPlayerFromCharacter method.

However, this might fail if there is no player that corresponds to that character. Do you have anything in your game that might be considered a character (e.g. has a torso, Humanoid, and head) but is not controlled by a player (such as an NPC)?

If not then I'm afraid I'm out of ideas.
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