Error: String expected got table?

I’m currently working on tables which I am very new to, and I got this error:
image

This is my code:


local gamepasses ={
	
	["GSandwh"] = {
		[1] = {"Golden Sandwhich"}; -- Gamepass Name
		[2] = {11776033}; -- Gamepass ID
		[3] = {false}; -- Roblox Premium get it?
		[4] = {"Join"}; -- Purchase button text
	};
	["ColorfulName"] = {
		[1] = {"Colorful Name"};
		[2] = {11817419};
		[3] = {false};
		[4] = {"Purchase"};
	};
	["island"] = {
		[1] = {"Island access"};
		[2] = {11817397};
		[3] = {true};
		[4] = {"Purchase"};
	};
	["JetSki"] = {
		[1] = {"JetSki"};
		[2] = {11817399};
		[3] = {false};
		[4] = {"Purchase"};
	};
	["SelifeStick"] = {
		[1] = {"Selfie Stick"};
		[2] = {11817422};
		[3] = {false};
		[4] = {"Purchase"};
	};
	["Balloon"] = {
		[1] = {"Balloon"};
		[2] = {11817431};
		[3] = {false};
		[4] = {"Purchase"};
	};
	["Hoverboard"] = {
		[1] = {"Hoverboard"};
		[2] = {11817406};
		[3] = {false};
		[4] = {"Purchase"};
	};
};





for _, TablePass in pairs(gamepasses) do
	local NewPass = script.Parent.Store.Passes.GamepassTemplate:Clone()
	NewPass.Parent = script.Parent.Store.Passes
	NewPass.GamepassName.Text = TablePass[1]
	NewPass.GamepassID.Value = TablePass[2]
	NewPass.RbxPremium.Value = TablePass[3]
	NewPass.Purchase.Text = TablePass[4]
	NewPass.Name = "Pass"
	local PosToSend = LastPos + UDim2.new(0,0,0.134,0)
	NewPass.Position = PosToSend
	LastPos = PosToSend
	wait(0.1)
	NewPass.Purchase.Prompt.Disabled = false
	NewPass.Visible = true
end

Lets look at the code that defines each TablePass

Each element inside a TablePass is also a table. You’re trying to set the Text and Value properties of an instance to a table which wont work. If there is no reason for each element of a TablePass to be a table then remove then remove the table declarations around each item.

Like this:

local gamepasses ={
	
	["GSandwh"] = {
		[1] = "Golden Sandwhich"; -- Gamepass Name
		[2] = 11776033; -- Gamepass ID
		[3] = false; -- Roblox Premium get it?
		[4] = "Join"; -- Purchase button text
	};
	["ColorfulName"] = {
		[1] = "Colorful Name";
		[2] = 11817419;
		[3] = false;
		[4] = "Purchase";
	};
	["island"] = {
		[1] = "Island access";
		[2] = 11817397;
		[3] = true;
		[4] = "Purchase";
	};
	["JetSki"] = {
		[1] = "JetSki";
		[2] = 11817399;
		[3] = false;
		[4] = "Purchase";
	};
	["SelifeStick"] = {
		[1] = "Selfie Stick";
		[2] = 11817422;
		[3] = false;
		[4] = "Purchase";
	};
	["Balloon"] = {
		[1] = "Balloon";
		[2] = 11817431;
		[3] = false;
		[4] = "Purchase";
	};
	["Hoverboard"] = {
		[1] = "Hoverboard";
		[2] = 11817406;
		[3] = false;
		[4] = "Purchase";
	};
};
1 Like

Thanks! @royaltoe also provided this soloution via DM.

1 Like