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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 05:12 PM |
| :GetPlayerFromCharacter method. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|