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
 

Why wont this work!

Previous Thread :: Next Thread 
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:31 PM
Im making a dodgeball tool, and I want it so that you gain 1 "point" when you hit someone, please help. This is what I have that just wont work.

function onTouched(player)
local plaay = player.Parent
local humanoid = plaay:findFirstChild("Humanoid")
local stats = game.Players:findFirstChild(player).leaderstats
if stats ~= nil and plaay ~= nil then
local Points = stats:findFirstChild("Points")
Points.Value = Points.Value + 1
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
30 May 2013 09:32 PM
Output?

http://www.roblox.com/My/Groups.aspx?gid=66545
Report Abuse
RobotWallE is not online. RobotWallE
Joined: 17 Jan 2009
Total Posts: 498
30 May 2013 09:32 PM
Output?
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:33 PM
All it says is that "local stats = game.Players:findFirstChild(player).leaderstats" is an "attempt to index a nil value"
Report Abuse
RobotWallE is not online. RobotWallE
Joined: 17 Jan 2009
Total Posts: 498
30 May 2013 09:34 PM
That means it doesn't exist. Maybe reorder your code.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
30 May 2013 09:35 PM
Either stats or leaderstats does not exist.

http://www.roblox.com/My/Groups.aspx?gid=66545
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:36 PM
Well, it works as a button but as a tool, it wont work.
Report Abuse
RobotWallE is not online. RobotWallE
Joined: 17 Jan 2009
Total Posts: 498
30 May 2013 09:37 PM
Use Hopperbins.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
30 May 2013 09:39 PM
local stats = game.Players:FindFirstChild(plaay.Name):FindFirstChild("leaderstats")

- You tried using the 'FindFirstChild()' method, with an object as an argument (part). It takes a string.

Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:44 PM
Hopper Bins wont work

Thanks @above
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:48 PM
Actually, it didnt even work.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
30 May 2013 09:53 PM
And it'd be nice if you posted any change in output. That was just something that was quite an obvious fault...
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
30 May 2013 09:56 PM
Ive already said "attempt to index a nil value"
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
30 May 2013 10:07 PM
function onTouched(player)
local plaay = player.Parent
local humanoid = plaay:findFirstChild("Humanoid")
if not humanoid then return end--maybe check if it's a character?
local stats = game.Players:findFirstChild(plaay.Name).leaderstats
if stats ~= nil and plaay ~= nil then
local Points = stats:findFirstChild("Points")
Points.Value = Points.Value + 1
end
end

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