The script is supposed to change the npc into a random friend on the users friendslist. Why won’t it work? The localscript is in the workspace. Please let me know.
local usernames = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
local friends = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(friends, item.Id) -- change store Id instead of Username
end
local randomFriend = friends[math.random(#friends)]
local npc = game.Workspace.npc
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(randomFriend)
npc.Humanoid:ApplyDescription(newHumanoidDescription)
I get no errors in the output, but the dummy doesn’t change appearences.
I suggest you do a bit of debugging and check that you are gathering your information properly. Try print the table friends and see if it has the data you are looking for.
function iterPageItems(pages)
local currentPage = pages:GetCurrentPage()
return currentPage:GetChildren()
end
local usernames = {}
local friends = {}
local usernames = {}
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) -- change store Id instead of Username
end
local randomFriend = friends[math.random(#friends)]
local npc = game.Workspace.npc
local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(randomFriend)
npc.Humanoid:ApplyDescription(newHumanoidDescription)