Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"keys must be strings" error?

Asked by 8 years ago

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?

0
What does "Script Analysis" say? And which script exactly says the error? TheHospitalDev 1134 — 8y
0
It's the localscript that gets error. And Script Analysis doesn't say anything. DangCoolIsReal 32 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

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

local Settings = {
["Admins"] = { -- Big no no.
[74629147] = true,
}
}
0
It's probably not the table, it's probably that number as a key. BlueTaslem 18071 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

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
0
... this isn't at all different. In general the preferred string is "" anyway... BlueTaslem 18071 — 8y

Answer this question