Getting the head of a friend via local script?

Hi, I am trying to make a game like Escape the running head except the heads are your friends! I am trying to figure out how to make heads become the friends head when they spawn. I wish to have a local script inside the head of the model and get some code for that. I have tried again and again but it just won’t work for me at all.

Screenshot of the model on explorer:

(Local script has not been placed inside)

If you have any questions feel free to ask! :slight_smile: thank you!

1 Like

i think you can get their description, and then only retrieve the head and hat etc
put them into your description and apply to the character

You will need to amass the local player’s friends through an exhaustive algorithm that traverses all pages of the player’s paginated friends. I recommend building a function that does this. It will begin with Players:GetFriendsAsync, which returns a FriendPages object. If you’re not sure how to exhaust paginated data, Roblox has several examples up on related Pages API references. The lot take the generator approach, which can be traded for an iterative approach in this scenario. The linked “Pages” site demonstrates an iterative approach with its pagesToTable function.

Once you have an array of all the local player’s friends, you can select a friend at random by indexing the array with a randomly generated natural number from 1->#array. Once you have that friend, you can use the HumanoidDescription system in tandem with the friend’s user ID to retrieve information about their head and related accessories. You could also experiment with Players:CreateHumanoidModelFromUserId to create a dummy rig which you can remove the other limbs and accessories from, then scale