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: Leaderstat finding on a weapon.

Previous Thread :: Next Thread 
Fazana is not online. Fazana
Joined: 21 Feb 2009
Total Posts: 28722
26 Dec 2013 05:05 PM
I have got a sword, that's simple enough.
Currently, it does 10 to 20 damage, and when it hits the enemy, it inflicts that.
Yeah, easy.

But when you level up a tonne and you're stuck with that same weapon, it feels a little weak. So I added a strength attribute to the leaderboard called Strength under leaderstats.

To make effect to the weapon, I'm trying to find said variable in the weapon.

My lack of coding expertise is showing that I can't get the player variable to register so I can find the leaderstat variables. The output doesn't tell me anything.

Here is a sample of the code.

local extradamage = player.leaderstats.Strength.Value


My whole script breaks at this point, saying that

attempt to index global 'player' (a nil value)

In a nutshell, can you explain what it means by this, and what would be the correct way to finding said player?

It's under a script, not a localscript.

Thanks



#Eating cake since 1996.
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
26 Dec 2013 05:08 PM
So, if the script is inside a sword, you'd go with parents.

IF it is like this:

StarterPack:
-Sword
--Script
--Handle



Then you use this:

player = script.Parent.Parent.Parent
Report Abuse
Fazana is not online. Fazana
Joined: 21 Feb 2009
Total Posts: 28722
26 Dec 2013 05:11 PM
Nah, the script activates when out, so

script.Parent.Parent would take you to your character.

#Eating cake since 1996.
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
26 Dec 2013 05:12 PM
:GetPlayerFromCharacter method.
Report Abuse
CrniOrao is not online. CrniOrao
Joined: 12 Oct 2008
Total Posts: 2274
26 Dec 2013 05:13 PM
http://wiki.roblox.com/index.php/GetPlayerFromCharacter_%28Method%29
Report Abuse
Fazana is not online. Fazana
Joined: 21 Feb 2009
Total Posts: 28722
26 Dec 2013 05:16 PM
Thanks, I shall try that.

#Eating cake since 1996.
Report Abuse
Fazana is not online. Fazana
Joined: 21 Feb 2009
Total Posts: 28722
26 Dec 2013 05:18 PM
It worked, thanks for the help!

#Eating cake since 1996.
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