SlenderNonr Posted October 27, 2023 Posted October 27, 2023 How to fix: attempt to index ?(a number value) with key '1' (global 'dragostand')
Count_Nosferatu Posted October 27, 2023 Posted October 27, 2023 3 hours ago, MonkeySAN said: fix what? He is trying to perform an action with <dragostand[1]> And it <dragostand> is 'number'
MC874 Posted October 27, 2023 Posted October 27, 2023 Hi @SlenderNonr, send us the script. I believe you're trying to enumerate table on a global variable named "dragostand". Roughly like this: dragostand = {1,2,3,4} If so, you can enumerate it like this: # Enumerate key & value for key, value in ipairs(dragostand) do ... # Enumerate key for key in pairs(dragostand) do ... We're not wizard. We need context or the source of the problem.
CmP Posted October 27, 2023 Posted October 27, 2023 Another typical mistake that causes such error is wrong usage of returned value of "gg.choice" (or "gg.alert") function. Example of wrong and correct usage: local choice = gg.choice({"Option 1", "Option 2"}) -- Wrong usage, returned value is a number, not table if choice[1] == 1 then print("Option 1 has been chosen") end -- Correct usage if choice == 1 then print("Option 1 has been chosen") end
Question
SlenderNonr
How to fix:
attempt to index ?(a number value) with key '1' (global 'dragostand')
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.