How to find a player's random friend userid

hello. I want to make an NPC spawn button so when the player clicked on it the player’s random friend would spawn(i know how to spawn but I don’t know how to get the player’s random friend userid)

(also sorry for bad grammar)

This article should help!

1 Like

First add a ClickDetector to the part. I suggest limiting the MaxActivationDistance property (of the ClickDetector) this is how far the model or part can be clicked from.
After which you use the following code to run spawning your friend:

local ClickDet = script.Parent.ClickDetector -- Path to ClickDetector, please change this.

local function SpawnFriend(plr) 
    -- The plr parameter is the player who clicked on this part/model.
    -- Insert the code you created here.
end

ClickDet.MouseClick:Connect(SpawnFriend)