Attempt to index nil with 'attributes' cant find a solution!

I want to achieve this damage calculation actually do the damage as well, not just calculate it.I am trying to figure out a way to do it without having errors and crashing the module script. I am usually able to figure out problems on my own but have no experience with module scripts

  1. What is the issue? Include screenshots / videos if possible!

    image

I looked on DevHub searched everywhere, watched mr blox table/metable videos and other peoples. I have spent over 4 10 hour days trying to find a way to make this work in modulescript correct math is applied to the basedamage number value but nil to attributes crashes the module script i think, as well the damage is not applied


THANKS IN ADVANCE if you can offer me any help with this problem

Bulletweapon module Script

look to big on the page so i moved it to github

Weaponsystems and Networkcallbacks can be found on

It seems like the player doesn’t have anything in them called attributes, which is why it’s throwing an error. Are you creating anything there?

3 Likes

ya all my int values are created through my attributes gui its reading attributes and calculating the damage properly, hitdamage is 11 6dex/2 is 3 making it 14 i think the issue is the players data is not in the table/metatable and ive tried so many ways to put it in the module script and nothing worksimage

You can’t actually get the LocalPlayer in a module script unless it’s a client side module script, however you can send the LocalPlayer through a LocalScript to the module.

image same boat im in, looking everywere

Is the module required by a localscript or a serverscript?

it has many files Weapons Kit found here

more screenshots

so all the scripts are in replicated storage other than the 4 in the tool itself.

Bulletweapon module script is the only script that calls the HitDamge Numerical value so i started there to add my math equation to add the damage per dexterity

It looks like the module is run on both server and client as part of the system (note the localPlayer variable in the module is false when on the server, and the LocalPlayer when on client).

Instead of trying to directly access the player, make use of the BaseWeapon class’s own property, self.player, which is available inside both BulletWeapon and BowWeapon. This should return the correct player, both on the server and the client.

return math.max(self:getConfigValue("HitDamage", 10) * falloff, 0) + math.floor(self.player.attributes.Dexterity.Value/2)
2 Likes

bro OMG OMGOMGOMG I LOVE YOU SO MUCH, i swear i tried this before and it didnt work, must have CAPS the wrong letter or something image image everythings working as intended now no errors monsters taking damage <3<3<3