Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect if someone is playing your game?

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

✓ Accepted answer

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.

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.

2 comments

0

Thanks i was able to modifiy this with my own script and it worked!

0

Alright, glad to hear it! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.