I would like the mods in my game to be able to join other players when they report. Here is an example. prnt.sc/sw06xm
There are two ways to get a player. The first would be to use a DataStore
, and the other would be to use MessagingService
. I believe that the second option is the best, as it is not too reliant on a DataStore
. We are going to be trying to get the JobId
of the server that a player of the given UserId
is in. Once we have the JobId
, we can teleport to that player.
local MessagingService = game:GetService("MessagingService") local TeleportService = game:GetService("TeleportService") local Players = game:GetService("Players") function GetServerData(UserId) local PlaceId local JobId PlayerFoundConnection = MessagingService:SubscribeAsync("PlayerFound"):Connect(function(GivenUserId, GivenPlaceId, GivenJobId) if GivenUserId == UserId then PlaceId = GivenPlaceId JobId = GivenJobId PlayerFoundConnection:Disconnect() end end) MessagingService:PublishAsync("GetPlayer", UserId) repeat wait() until not PlayerFoundConnection.Connected return PlaceId, JobId end function TeleportPlayer(Player, PlaceId, JobId) TeleportService:TeleportToPlaceInstance(PlaceId, JobId, Player) end MessagingService:SubscribeAsync("GetPlayer"):Connect(function(UserId) for _, Player in pairs(Players:GetPlayers()) do if Player.UserId == UserId then MessagingService:PublishAsync("PlayerFound", UserId, game.PlaceId, game.JobId) end end end)
As you can see, we have two functions: GetServerData
, and TeleportPlayer
. These functions can be referenced later on in the script.
Edit:
People are saying you need help regarding Discord as well, so let me break that down for you as well. :)
Discord has this thing called Webhooks
, which are just a way of posting messages on Discord remotely (which in this case, is ROBLOX). A webhook can be added from a server or channel's configuration. I'll be showing you how I do Discord webhooks (with my module, as it makes things simpler).
local Discord = require(3427317493) local ModCallWebhook = Discord:GetWebhook("YOUR_WEBHOOK_URL") function PostModCall(Player, Message) ModCallWebhook:Post({ Content = string.format("**Moderator call from %s (%s):\n%s**", Player.Name, Player.UserId, Message) }) end