I don’t understand why my code won’t work. I get no forms of errors (output, underlines, etc) but it still won’t work. The code is supposed the make the npc change into a random player on the users friends list.
local usernames = {}
local friends = {}
local function iterPageItems(friendPages)
for item, pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
table.insert(friends, item.Id)
end
local friends = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(friends, item.Id)
end
local randomFriend = friends[math.random(#friends)]
local npc = game.Workspace.npc
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(randomFriend)
npc.Humanoid:ApplyDescription(newHumanoidDescription)
end
What are you trying to do with this? You’re calling the function inside of itself, it’s going to loop infinitely. Are you trying to make a custom iterator function?
No thats what confused me. I’m sorta a mid scripter and when I posted my script in the Development-Help channel in the Roblox discord, someone said I had to Define iterPageItems and I thought I did it right. How would I fix that? Is that the only bug?
you must have misunderstood, they meant “iterPageItems” is not a built in function so you have to define what you want it to do elsewhere, not put everything you made in it