Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to detect if someone is playing your game?

Asked by 4 years ago

Basically I want to have a gui that when a player types there name into if will see if the player is his or hers friend and then view if they are playing my game or not. If they are the player will teleport to that player. If not, the player won't. How can I:

1. Get the knowledge of if that player is playing my game

2. Teleport to that specific server that the players friend is in.

I've seen this done in plenty of games so I do know this is possible, but I just can't find any information explaining this.

1 answer

Log in to vote
1
Answered by 4 years ago

There really isn't a need to check that in a game because you can always check the person's profile, but I don't think it is possible to check across all servers and teleport to theirs.

  • This was taken from here: https://developer.roblox.com/en-us/api-reference/function/TeleportService/GetPlayerPlaceInstanceAsync
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    -- Is this player following anyone?
    local followId = player.FollowUserId
    -- If so, find out where they are
    if followId and followId ~= 0 then
        local success, errorMessage, placeId, jobId = pcall(function()
            return TeleportService:GetPlayerPlaceInstanceAsync(followId)
        end)
        if success then
            -- Teleport player
            TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
        end
    else
        warn("Player " .. player.UserId .. " is not following another player!")
    end
end)

If you could somehow use a double for loop to check all the players of all the servers (something that would likely take time and resources depending on amount), to find the desired player then you could get the id of the server they are on and send the player there.

0
Thanks i was able to modifiy this with my own script and it worked! Bl_ueHistory 94 — 4y
0
Alright, glad to hear it! :D Zavaldro 20 — 4y
Ad

Answer this question