Why is this spitting out "attempt to index nil with 'Text'"?
I'm trying to make a script so you can change your keybinds, and for the most part it's been pretty smooth, however it keeps spitting out "attempt to index nil with 'Text'" in this section of code. All that section of the local script is supposed to do is change the text of the keybindButton, which is a TextButton, and that's in it's own dictionary as well to make things more organized. The keys for the keybindButtons are the exact same as the keys inside KeybindModule.defaultKeybinds. I don't really understand what's wrong here, and everything I've been doing leads to the same error. I only just learned how to manipulate dictionaries a few days ago, so maybe that's my problem lol
Module code:
02 | KeybindModule.defaultKeybinds = { |
03 | toggleInventory = "tab" , |
04 | invDropAll = "rightClick" , |
05 | invDropAmount = "leftClick" , |
12 | switchToGrenade = "g" , |
13 | switchToOrdinance = "q" , |
17 | prone = "leftControl" , |
27 | function KeybindModule.getAllKeybinds(player) |
28 | local playerSettings = PlayerData:WaitForChild(player.UserId):WaitForChild( "_settings" ) |
29 | local returningDictionary = { } |
30 | for i, v in pairs (playerSettings:WaitForChild( "keybinds" ):GetChildren()) do |
31 | returningDictionary [ v.Name ] = v.Value |
33 | return returningDictionary |
Local script code:
1 | local keybinds = ControlModule.getAllKeybinds(player) |
3 | for keybindKey, keybindValue in pairs (keybinds) do |
4 | if keybindValue = = nil or keybindKey = = nil then |
5 | keybindButtons [ keybindKey ] .Text = string.upper(ControlModule.defaultKeybinds [ keybindKey ] ) |
7 | keybindButtons [ keybindKey ] .Text = string.upper(keybindValue) |
Any help is greatly appreciated.