. . . Posted November 21, 2016 Share Posted November 21, 2016 (edited) Hello, I have a problem I can't fix myself . If someone could help me that would be great ! This's the code local equip = inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) equip.components.finiteuses:Use(10) What I want to do is damage the equip by 10 points but the game crashes saying "attempt to index field finiteuses a nil value" even though my equip has that component! This is inside modmain.lua, I would appreciate any kind of help ! Edited November 21, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71884-solved-attempt-to-index-field-finiteuses-a-nil-value/ Share on other sites More sharing options...
CarlZalph Posted November 21, 2016 Share Posted November 21, 2016 GetEquippedItem can return nil, so check against that before touching it. There's also the case that whatever is being held doesn't have that component and so there's another thing you'd need to check against. If you're wanting a specific prefab to be affected then compare against the equip's prefab name to the one you want. Link to comment https://forums.kleientertainment.com/forums/topic/71884-solved-attempt-to-index-field-finiteuses-a-nil-value/#findComment-839977 Share on other sites More sharing options...
. . . Posted November 21, 2016 Author Share Posted November 21, 2016 2 hours ago, CarlZalph said: There's also the case that whatever is being held doesn't have that component and so there's another thing you'd need to check against. This was the problem, I did this & it worked! Thanks man if equip.components.finiteuses then equip.components.finiteuses:Use(10) end Link to comment https://forums.kleientertainment.com/forums/topic/71884-solved-attempt-to-index-field-finiteuses-a-nil-value/#findComment-840036 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now