How can I load characters of a players friend?

Making a showcase, how can I script a code to load the characters of 2 players / 1 players from a players friend list

1 Like

More context? maybe you are talking about this.
image
image
I wish I can provide you the link for this plugin but I am pretty sure his account got deleted along with the plugin on marketplace, But found another one similar you can Install here or you can check out his devforum.

1 Like

Theres a :GetPlayerFriends function, something like that and someone told me you can randomize through the pages pick a random friend of the local player, create a character with that friends description

1 Like

You can use the :GetPlayersFriends() function to get the friends, then use another function which I forget the name of on a humanoid to apply that player’s character to that humanoid. It will automatically change the scale, skin color, and add accessories.

This is how all those games that make your friends appear as npcs work
ApplyHumanoidDescription I think it’s called

1 Like

Thing is i want to randomize the list for 1 friend, and how do you even use that function? insert it into a table for the friends userid

GetPlayerFriends(UserId) returns a table that can be accessed with GetCurrentPage()

Turn that into a code example and you have my attention

function Module.GetFriends(UserId)
	return PS:GetFriendsAsync(UserId):GetCurrentPage()
end

function Module.CreateVisualNPC(Info)
	local GetFriends = Module.GetFriends(Player.UserId)
	if 1 then return end
	for i,v in GetFriends do
		local Info = PS:GetHumanoidDescriptionFromUserId(v.Id)
		local Clone = NPCClone:Clone()
		local Humanoid = Clone:WaitForChild("Humanoid")
		Info.DepthScale = Humanoid.BodyDepthScale.Value
		Info.BodyTypeScale = Humanoid.BodyTypeScale.Value
		Info.WidthScale = Humanoid.BodyWidthScale.Value
		Info.HeightScale = Humanoid.BodyHeightScale.Value
		Info.ProportionScale = Humanoid.BodyProportionScale.Value

		Clone.Parent = game.Workspace
		Humanoid:ApplyDescription(Info)
	end
end

I know this works it’s in one of my games

Doesn’t seem to work, this is what i did

local function GetFriends(UserId)
	return game.Players:GetFriendsAsync(UserId):GetCurrentPage()
end

local function onPlayerAdded(plr)
    local dummy = script:WaitForChild("Dummy")	
    local desc = game.Players:GetHumanoidDescriptionFromUserId(plr.UserId)
    local clone = dummy:Clone()
	
	local GetFriends = GetFriends(plr.UserId)
	for i,v in GetFriends do
		local Info = game.Players:GetHumanoidDescriptionFromUserId(v.Id)
		local Clone = script.Friend:Clone()
		local Humanoid = Clone:WaitForChild("Humanoid")
		Info.DepthScale = Humanoid.BodyDepthScale.Value
		Info.BodyTypeScale = Humanoid.BodyTypeScale.Value
		Info.WidthScale = Humanoid.BodyWidthScale.Value
		Info.HeightScale = Humanoid.BodyHeightScale.Value
		Info.ProportionScale = Humanoid.BodyProportionScale.Value

		Clone.Parent = game.Workspace.Rigs
		Humanoid:ApplyDescription(Info)
	end

    clone.Parent = workspace.Rigs
    clone.Name = plr.Name.."Rig"
    clone:WaitForChild("Humanoid"):ApplyDescription(desc)
    clone.HumanoidRootPart.Transparency = 1
end

local function onPlayerRemoved(plr)
    if workspace.Rigs:FindFirstChild(plr.Name.."Rig") then
        workspace.Rigs:WaitForChild(plr.Name.."Rig"):Destroy()
    end
end

game.Players.PlayerAdded:Connect(onPlayerAdded)
game.Players.PlayerRemoving:Connect(onPlayerRemoved)

What is the problem? Is there an error?

Nope, clear of any error … word limit