I'm using a script for creating and loading characters, but whenever I click Load, I get this error:
Players.Player.PlayerGui.ScreenGui.Frame.LocalScript:24: bad argument #3 to 'Text' (string expected, got table)
wait(0.43)
local module = require(game:GetService('ServerScriptService'):WaitForChild('ModuleScript'))
local characters = {}
table.insert(characters,module.getChars(game.Players.LocalPlayer.UserId))
local pos = 0.15
script.Parent:WaitForChild('Create').MouseButton1Click:connect(function()
script.Parent:WaitForChild('Create').Visible = false
script.Parent:WaitForChild('Load').Visible = false
script.Parent:WaitForChild('CC').Visible = true
script.Parent:WaitForChild('Name').Visible = true
end)
script.Parent:WaitForChild('CC').MouseButton1Click:connect(function()
module.createCharacter(script.Parent:WaitForChild('Name').Text,game.Players.LocalPlayer.UserId)
end)
script.Parent:WaitForChild('Load').MouseButton1Click:connect(function()
script.Parent:WaitForChild('Load').Visible = false
script.Parent:WaitForChild('Create').Visible = false
for _, v in pairs(characters) do
local a = script.Parent:WaitForChild('Template')
a.Text = v
a.Name = v
a.Position = UDim2.new(0.035, 0,pos, 0)
a.Visible = true
pos = pos + 0.10
end
end)
EDIT: This is what getChars basically does
local t = {}
table.insert(t,ds3:GetAsync(player ..'_chars'))
return t

8 comments
getChars might be returning a table. Since you're inserting a table into
characters, when you iterate through it at line 22, v is a table. It might be helpful to post what getChars does.GetChars just checks the datastore for player characters and returns a table of all the characters, but I thought Line 22 was supposed to convert each value into a string e.e
Line 5 appears to be inserting a table into the characters table. If you're just using the information from the module function, it would be simpler to redefine the characters table.
I'm using my module because that's where I have all my functions to save, load, set data ect. But the error is that "v" is a table :(
I added what getChars does
@TimeLordSir Is the datastore entry a table? If so, you'll need to iterate through another table on line 24 and 25.
@Shawnyg Can you give an example please?
@TimeLordSir Sure. I'll post it as an asnwer