Unable to get table

Hello everybody, I am working on saving which zones a player owns or does not(like how pet sim x has a pixel world or the basic world). My issue is that I cant get the table, it prints nil and I am pretty I got the table.

local DSS = game:GetService("DataStoreService")
local zonesOwned = DSS:GetDataStore("zonesOwned")
-- Getting a data store



game.Players.PlayerAdded:Connect(function(plr)
	local Zones = {}-- zone2, zone3 stuff like that
	
	table.insert(Zones,plr:WaitForChild("ZoneOwnershipValueFolder"):GetChildren())
	print(Zones.Name)-- prints nil

	
	
	local data
	local success, errormessage = pcall(function()
		 data = zonesOwned:GetAsync(plr.UserId)
	end)
	
	if data ~= nil then 
		Zones[1].Value = data[1]
		Zones[2].Value = data[2]
		Zones[3].Value= data[3]
		Zones[4].Value = data[4]
		Zones[5].Value = data[5]-- assigning the data a key 
		print("Successfully gotten data")
	else
		print("unable of getting player data")
		warn(errormessage)
		
	end
	
end)



game.Players.PlayerRemoving:Connect(function()
	
end)

Screenshot 2022-08-09 102143
You can see its right there but the output says nil when I try to print the name. How do I solve this.

You are trying to print Zones.Name but there is nothing in the table under “Name”. Try printing just Zones.

1 Like