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)
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)
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)