Key ‘___’ not found in table ‘{any}’ error

I don’t know if I might be doing something wrong or if Roblox has a bug right now. But this is what’s happening:

local function onBuy(player: Player, args: {any}): (boolean, string?)

   local name = args.ItemName
   --[[
for some reason, under the
args.ItemName, it has the orange
squiggly line and when you hover
over it, it gives the error(in the
title of this post. Replace the
___ with ItemName)
This doesn’t make sense at all
because it says it should be any
type in the {any} thing in the
parameters.
   ]]
end

Does anyone know how to fix this? Thanks

Question first, are you using any special scripting setting, like strict?

You should try looking here:

This explains a lot about type checking, i tried to find something in it but it was very long for me to read.

1 Like

I tried using both nonstrict and strict already. It also wouldn’t make sense for the bug to appear either way anyways. I’ve also done stuff like this before and it’s never done this once. I even tried doing an if statement like this

if args.ItemName then

And it still does the orange squiggly line error

Can you try putting this script into studio and see if it happens for you too?

1 Like

The issue is that you are telling the script to expect an array (args: {any}), but then try to treat it as though it is a dictionary (args.ItemName).

Try replacing the typecheck either with a dictionary type (containing all possible keys), or just use any (as opposed to {any}

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.