Invalid argument #1 to 'next' (table expected, got string)

You can write your topic however you want, but you need to answer these questions:

  1. Im trying to get the definition of a word and seperating each definition

  2. The issue is theres a error “invalid argument #1 to ‘next’ (table expected, got string)”

  3. I looked in the developer hub and looked on youtube

function getDefinition(word)
	local url = "https://api.dictionaryapi.dev/api/v2/entries/en/"..word
	local Async = HttpService:GetAsync(url)
	local data = HttpService:JSONDecode(Async) -- Getting the code and turn it into roblox form
	for i, things in pairs(data) do
		local meanings = things.meanings
		for i, num in pairs(meanings) do
			for i,nums in pairs(num) do
				local definitions = nums.definitions
				local lastdefinitions = 0

				for i, v in next, nums  do
					lastdefinitions += 1
				end
				wait()
				
				local MinNum = 0
				local MaxNum = lastdefinitions
				for r = MinNum + 1, MaxNum - 1 do
		
					print(r)
	--				game.ReplicatedStorage.GetDefinition:FireClient(r,nums[r].definition)
	
				end
			end
		end
	end

end

nums is being defined as a string, not a table.

I’m thinking you have one too many loops based on this.

how would I lessen the loops or should I change the script?

Just remove one of the loops, I think your table probably looks like,

local data = {
    meanings = {
        {1,2,3,4};
        {123456,123,1,2};
    };
}

so each time it gets to the tables inside of meanings, it’s trying to iterate through the number.

Try removing this loop:

for i,nums in pairs(num) do

How can I remove my loop?

if SkinsData then
		print(SkinsData)
		local Table = HttpService:JSONDecode(SkinsData)
		for i, v in pairs(Table) do
			local newv = v:Clone()
			newv.Parent = OwnedSkins
		end
	else
		Skins_data:SetAsync(player.UserId,"")
	end