Script can't see a thing inside array even though its there?

Hi,

So im getting this error, and as i see script can’t see the things under key 5?
Screenshot_296

This is what on line 67. I want to update do function UpdateKeybinds and also give it a dictionary with all keybinds, but it gives an error.
Screenshot_297

As you can see on screenshot 1 under key 5 is table with all keybinds and to print it i did:
print(game.HttpService:JSONEncode(data))
But when i try to get only key 5 it gives error. I also tryed doing any other things with key 5 (like printing only it/other functions) but this still gave an error. What im doing wrong?

2 Likes

Can we see more of the code please, it would be helpful.

1 Like

I think thats the end of output or it is not.

I’m not talking about the output, I’m talking about the actual code.

local DataChangedEvents = {
	[2] = function()
		GuiService:UpdateGold(data[2])
	end,
	[3] = function()
		GuiService:UpdateKarma(data[3])
	end,
	[5] = function()
		GuiService:UpdateKeybinds(data[5])
	end,
}

This is list of functions that i do when data changing.
When client got data from server i hold it under variable called “data”
and do all update functions:

for a, b in pairs(data) do
	local f = DataChangedEvents[a]
	if f then
		spawn(f)
	end
end

But it gives an error when i test it intantly when this function happens. have no idea why

So according to error, you’re trying to call a nil value as a function so looking at the line that caused the error, it means that GuiService:UpdateKeybinds doesn’t exist.

This is like data table looks like if output text looks messy:

local example = {
	[1] = 1234, -- Gold
	[2] = 3141, -- Crystals
	[5] = { --Keybinds
		Inventory = "Enum.Keycode.E",
		Settings = "Enum.Keycode.X"
	},
	[6] = { -- quests
		Quest_1 = {
			Name = "Idk",
			Desc = "Example text here",
			Reward = {
				Gold = 100,
				Crystals = 5,
			}
		}
	},
}

GuiSevice exist because other functions (2,3) is doing well.
:UpdateKeybinds exist because i checked:
Screenshot_298
so only data[5] is missing

That’s odd, what’s inside the :UpdateKeybinds() function?

oh nevermind this wasn’t working since :UpdateKeybinds() was inside another function. I put it there to make it easier to change variables inside that parent function. I put it outside and now it works

If you read the error, it simply says you’re trying to call a function that doesn’t exist, therefore attempt to call a nil value

ye i understood it before, but i couldn’t figure out why it says it do not exits if it is lol