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.
To use the FriendsLocator module in an experience:
- Visit the FriendsLocator marketplace page, click the green Get button, and confirm the transaction.
- In Studio, open the toolbox (View → Toolbox).
- Select your toolbox Inventory section.
- Locate the module item and click it or drag-and-drop it into the 3D view.
- 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.
Advanced Installation Options »
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.
Instance/Destroy|Destroy()run on it immediately after this event is fired.
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.
- In StarterPlayerScripts, create a new
LocalScriptand rename it ConfigureFriendsLocator.
- 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.
- From the Test tab, select the following combination for Clients and Servers.
- Click the Start button and three instances of Studio will open; one simulated server and two simulated clients.
- 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.
Workspace/StreamingEnabled|StreamingEnabledshould implement custom content pre-streaming around the teleport location, although this behavior will be built into future versions of the module.
Connecting to Events
The FriendsLocator module exposes events so that you can introduce custom behaviors when users interact with a locator icon.
- Make sure that you’ve created the ConfigureFriendsLocator script outlined in Testing in Studio.
- Add the highlighted lines to the script:
- 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.
Overrides the default configurations with the given values.
|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.|
Fires when a locator icon is clicked/activated by the local player.
Fires when a locator icon is shown/hidden on the local player’s screen.
|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