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

Why does my error say that I gave a string value a table?

Asked by 4 years ago
Edited 4 years ago

I am working on saving players data and when I run I get the error, "invalid argument #3 (string expected, got table)"

Why could this be?

The error is on line 5

local backpackKey = "user_" .. player.userId .. "_backpack"
local backpack = dataStore:GetAsync(backpackKey)
local bpObject = Instance.new("StringValue")
bpObject.Name = "BackpackItem"
bpObject.Value = backpack
bpObject.Parent = player
0
What is backpack equal to.....? Ziffixture 6913 — 4y
0
if bpObject.value is coming up as an error then it means that whatever your "backpack" variable is is a table instead of a string HEMAN_9 70 — 4y
0
Look at the variables. DARWINTHEMINION2 37 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

local backpack = dataStore:GetAsync(backpackKey) I believe this line is returning a table of data.

Such as {"value", "value", "value"}.

You be wanting to do something like

bpObject.Value = backpack[1]
Ad

Answer this question