PcoWSkbVqDnWTu_dm2ix

Friends Locator

Friends Locator

It can be challenging to locate friends in-experience. The FriendsLocator developer module lets players easily find and teleport to their friends inside a place.

Module Usage

Installation

To use the FriendsLocator module in an experience:

  1. Visit the FriendsLocator marketplace page, click the green Get button, and confirm the transaction.
  2. In Studio, open the toolbox (ViewToolbox).
  3. Select your toolbox Inventory section.
  1. Locate the module item and click it or drag-and-drop it into the 3D view.
  2. In the Explorer window, move the entire FriendsLocator folder into ServerScriptService. Upon running the experience, the module will distribute itself to various services and begin running.

This and other developer modules come with an Install script that runs the installer and distributes the contents of the module to the same services that the folders are named after.

The Install script can be utilized as follows:


EnableLogging — Set to true to enable debug logging for the current developer module. This lets you see how the module gets distributed, along with how each package is linked.


InstallStarted — Fires when the installer first starts up. You can hook into this event to run any pre-install steps.


InstallFinished — Fires when the installer has finished installing the module. By this point, the contents of each service folder has been distributed. You can also hook into this event to run any post-install steps.


Install() — Installs the given developer module by overlaying each of the service folders over existing services. For example, a folder named ReplicatedStorage containing a FriendsLocator script will be distributed to game.ReplicatedStorage.FriendsLocator when installing.


Testing in Studio

To test the module in Studio, the FriendsLocator module must be run in a multi-client simulation, since no friends will be present in a solo playtest.

  1. In StarterPlayerScripts, create a new LocalScript and rename it ConfigureFriendsLocator.
  1. Paste the following code into the new ConfigureFriendsLocator script. The setting on line 7 ensures that locators are shown for all users while testing in Studio, but not in a published place.
  1. From the Test tab, select the following combination for Clients and Servers.
  1. Click the Start button and three instances of Studio will open; one simulated server and two simulated clients.
  1. Go into either of the client Studio instances, zoom out, and you should see a locator icon over the other character. Note that locator icons only appear when the camera is a minimum distance away from a friend, at a default of 100 studs.

Connecting to Events

The FriendsLocator module exposes events so that you can introduce custom behaviors when users interact with a locator icon.

  1. Make sure that you’ve created the ConfigureFriendsLocator script outlined in Testing in Studio.
  2. Add the highlighted lines to the script:
  1. Conduct a multi-client test and click on another character’s locator icon. Notice that your character does not teleport to that location, and the event triggers to allow for custom handling of icon clicks.

API Reference

Functions

configure()

void configure ( table config )

Overrides the default configurations with the given values.

Key Default Description
alwaysOnTop true If true, shows locator icons on top of everything, preventing them from being blocked by 3D world objects.
showAllPlayers false If true, shows locations for all players, not just friends. Setting this to true can help verify the module's functionality in Studio.
teleportToFriend true Teleports player character to the friend's location when their locator icon is clicked or tapped.
thresholdDistance 100 Camera distance threshold at which locator icons appear; friends closer than this distance will not display icons.
maxLocators 10 Maximum number of locator icons shown at any given time.

Events

clicked

RBXScriptConnection clicked ( Player player, CFrame playerCFrame )

Fires when a locator icon is clicked/activated by the local player.

Parameter Description
player Player object that the locator icon belongs to.
playerCFrame datatype/CFrame of the player's Humanoid/RootPart that the locator icon belongs to.

visibilityChanged

RBXScriptConnection visibilityChanged ( Player player, CFrame playerCFrame, bool isVisible )

Fires when a locator icon is shown/hidden on the local player’s screen.

Parameter Description
player Player object that the locator icon belongs to.
playerCFrame datatype/CFrame of the player's Humanoid/RootPart that the locator icon belongs to.
isVisible Whether the locator icon is currently visible on the local player's screen. Note that this will still be true if alwaysOnTop is false and the locator renders behind an object in the 3D world.

Next In-Experience Profile