How to call table from string value

	local PlayersinSt = {}
	local PlayersinCM = {}
	local PlayersinCM1 = {}
	local PlayersinCM2 = {}
	local PlayersinGK = {}
	local PlayersinLW = {}
	local PlayersinRW = {}

	local MaxPlayerinSt = 1
	if Positions.Frame.Visible == true then
		Positions.Frame.Visible = false
	elseif Positions.Frame.Visible == false then
		for i,v in pairs(Positions.Frame:GetChildren()) do
				--local tablelist = "Playersin".. (v.Name)
				print("Button clicked")
				if not table.find("Playersin".. (v.Name), player) then
					print("Player added")
					table.insert("Playersin".. (v.Name), player)
					v.Text = player.Name

I need to call the table from a string value I have no idea how to do that since Im using a loop.
This is the line I need help
table.insert(“Playersin”… (v.Name), player)
The error says that it is a string value not table. I need to get the table from up there.

What you want to do is impossible, you cannot access a defined variable in memory using a string or anything other than the name in the code.
You’d need to change the structure of the data.
Maybe do this instead

local Playersin = {
	PlayersinSt = {},
	PlayersinCM = {},
	PlayersinCM1 = {},
	PlayersinCM2 = {},
	PlayersinGK = {},
	PlayersinLW = {},
	PlayersinRW = {},

then replace the table.insert line with this

table.insert( Playersin["Playersin".. (v.Name)] , player)
1 Like

Thank you so much I had no idea i had to do all that good looks lil dude

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.