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 » Scripters
Home Search
 

Re: Attempt to index local leaderstats (a nil value)

Previous Thread :: Next Thread 
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 04:54 PM
Ok, what's going on..

One.Touched:connect(function(plr)
local leaderstats = plr.Parent:FindFirstChild("leaderstats")
local Stage = leaderstats:FindFirstChild("Stage")
if plr.Parent:FindFirstChild("leaderstats") and plr.Parent:FindFirstChild("Stage") then
print("Found them")
end
end)
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 04:56 PM
a part of unknown type will touch the brick, that's not how you check / get the player.


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
13 Sep 2015 04:56 PM
plr is a part of a character


so


One.Touched:connect(function(char)
local plr = game.Players:GetPlayerFromCharacter(char)
local leaderstats = plr.Parent:FindFirstChild("leaderstats")
local Stage = leaderstats:FindFirstChild("Stage")
if plr.Parent:FindFirstChild("leaderstats") and plr.Parent:FindFirstChild("Stage") then
print("Found them")
end
end)
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 04:58 PM
@Per

Attempt to index local plr (a nil value)
Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
13 Sep 2015 04:59 PM
char.Parent sorry
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 04:59 PM
Perilous is wrong lol


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:00 PM
Here's the leaderstats if I did something wrong here too.

-- Made by SurfaceLight

game.Players.PlayerAdded:connect(function(Player)
local Leaderstats = Instance.new("IntValue",Player)
Leaderstats.Name = "leaderstats"
Leaderstats.Value = 0
local Stage = Instance.new("IntValue", Leaderstats)
Stage.Name = "Stage"
Stage.Value = 0
end)
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:02 PM
Why isn't it finding the leaderstats... No matter how I define it, it's always going to error. ._.
Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
13 Sep 2015 05:03 PM
print the name of what it touched and that'll help
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Sep 2015 05:03 PM
Use the GetPlayerFromCharacter function like this:

One.Touched:connect(function(plr)
local leaderstats = game.Players:GetPlayerFromCharacter(plr.Parent):FindFirstChild("leaderstats")
local Stage = leaderstats:FindFirstChild("Stage")
if plr.Parent:FindFirstChild("leaderstats") and plr.Parent:FindFirstChild("Stage") then
print("Found them")
end

end)
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 05:04 PM
you're going to get a part to fire Touched. it could be a torso, an arm, a leg, a bullet, a gun, any number of things. check if hit.Parent is valid, check if GetPlayerFromCharacter(hit.Parent) is a player, and go onwards


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:05 PM
@fish

Attempt to index a nil value.

What is going on?
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 05:06 PM
read what i said


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:06 PM
I already did, and that won't change a single thing.
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:16 PM
Help
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Sep 2015 05:19 PM
Here, I will rewrite this

Give me a few minutes
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Sep 2015 05:25 PM
local One = workspace.Baseplate -- Change this to what "One" is


One.Touched:connect(function(Hit) -- Setting up an annoymous function for when "One" is touched
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) -- Getting the player that touched the part
if Player then -- Checking if the player exists
local Leaderstats = Player:FindFirstChild("leaderstats")
local Stage = Player:FindFirstChild("leaderstats"):FindFirstChild("Stage")
if Leaderstats and Stage then
print("Found them")
else
print("Didnt find them")
end
end
end)

This should work
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
13 Sep 2015 05:27 PM
So much is wrong. First,

leaderstats has to be lowercased for it to be valid.

Also, plr.Parent is the Players service, so I don't know what you're doing.

I think this is what you're looking for looking at original post.

One.Touched:connect(function(hit)
local leaderstats = game.Players:GetPlayerFromCharacter(hit.Parent)
local Stage = leaderstats:FindFirstChild("Stage")
if leaderstats and leaderstats:FindFirstChild("Stage") then
print("Found them")
end
end)
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:28 PM
@laugh You're wrong, because 1. It worked when I joined the game in online mode, and 2. I'm trying to get the PLAYERS service so I can get into that players leaderstats and change the value. It doesn't take an idiot to figure that out.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Sep 2015 05:28 PM
"leaderstats has to be lowercased for it to be valid.

Also, plr.Parent is the Players service, so I don't know what you're doing."

1.It is, the variable is with a capital L but if you look at it's value, you'll see it's lowercase dumbo


2. No it isnt. It is getting the CHARACTER or the person that touched it because in his case, "plr" returns the part touching and plr.Parent returns the parent of the part(the character)
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
13 Sep 2015 05:35 PM
Wow you guys are so smart!

Thumbs up!
Report Abuse
SurfaceLight is not online. SurfaceLight
Joined: 06 Apr 2014
Total Posts: 7574
13 Sep 2015 05:36 PM
Oh look, your guy's scripts still don't work.

*Face-Palm*
Report Abuse
laughablehaha is not online. laughablehaha
Joined: 19 Apr 2012
Total Posts: 2495
13 Sep 2015 05:38 PM
How can I help you ma'am
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
13 Sep 2015 05:41 PM
omg, it's like watching a train wreck.
fish and laugh gave correct answers.

@fish I'm pretty sure he was talking the OP, not your answer.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
13 Sep 2015 05:47 PM
Wait. What was I thinking?

"
local leaderstats = game.Players:GetPlayerFromCharacter(hit.Parent)
"

laugh's answer is wrong to. The FAIL is contagious in here. gtg
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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