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

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

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

3 comments

0

What is backpack equal to.....?

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

0

Look at the variables.

1 answer

✓ Accepted answer

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]

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