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: Output error

Previous Thread :: Next Thread 
xandon is not online. xandon
Joined: 31 Jul 2008
Total Posts: 1037
24 Jun 2013 01:34 PM
function onTouched(hit)
friend = script.Parent.Friends
enimy = script.Parent.Enimies
a = script.Parent.Parent.Flag
b = game.Players:GetPlayerFromCharacter(hit.Parent)
if b.TeamColor == a.BrickColor then
friend.Value = friend.Value + 1
end
if b.TeamColor ~= a.BrickColor then
enimy.Value = enimy.Value + 1
end
end
script.Parent.Touched:connect(onTouched)

"Attempt to index global 'b' (a nil value)"

I don't understand what I've done wrong.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
24 Jun 2013 01:35 PM
game.Players:GetPlayerFromCharacter(hit.Parent) does not exist.
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
24 Jun 2013 02:01 PM
function onTouched(hit)

print("Hit: ", hit)

friend = script.Parent.Friends
enimy = script.Parent.Enimies
a = script.Parent.Parent.Flag
b = game.Players:GetPlayerFromCharacter(hit.Parent)

if b ~= nil -- if not a bullet or some mud -- might help

if b.TeamColor == a.BrickColor then
friend.Value = friend.Value + 1
end
if b.TeamColor ~= a.BrickColor then
enimy.Value = enimy.Value + 1
end

end -- Player?

end -- func
script.Parent.Touched:connect(onTouched)
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