Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

"keys must be strings" error?

So I have a localscript invoking a remote function, the script should return a table but instead get the error "keys must be strings" i'v never seen this type of error before. Both the localscript and script require the table for it to work.

Inside the localscript: (ERROR HERE)

local Settings = Cheats.GetSettings:InvokeServer()

Inside the script:

local Settings = {
	["Admins"] = {
		[74629147] = true,
	},
	["USER ID"] = true,
	["USER NAME"] = true,
	["FOG"] = true,
	["GOD MODE"] = true,
	["MAX HEALTH"] = 100,
	["FORCEFIELD"] = true,
}

GetSettings.OnServerInvoke = function(Plr)
	return Settings
end

Anyone know a solution?

2 comments

0

What does "Script Analysis" say? And which script exactly says the error?

0

It's the localscript that gets error. And Script Analysis doesn't say anything.

2 answers

Ok lesson learned, you can't return a table if that table has table in it.

local Settings = {
["Admins"] = { -- Big no no.
[74629147] = true,
}
}

1 comment

0

It's probably not the table, it's probably that number as a key.

If it says keys must be strings strings are usually ' '. So try this.

local Settings = {
    ['Admins'] = {
        [74629147] = true,
    },
    ['USER ID'] = true,
    ['USER NAME'] = true,
    ['FOG'] = true,
    ['GOD MODE'] = true,
    ['MAX HEALTH'] = 100,
    ['FORCEFIELD'] = true,
}

GetSettings.OnServerInvoke = function(Plr)
    return Settings
end

1 comment

0

... this isn't at all different. In general the preferred string is "" anyway...

This discussion is preserved as it was. New answers, comments, and votes are closed.