How to detect your friend joining the game

Is there an event that detects if your friend has joined the game or not? I am only aware of FriendService, but that doesn’t to anything.

2 Likes
2 Likes

What exactly do you mean? Cause whenever I’m playing a game, the system always messages me when a friend joins

1 Like

I am aware of that, but when the server messages, does it send an event with it?

There is a method of Player called :IsFriendsWith(), which will return a bool (either true or false depending if they’re friends or not.)

  • Example:
local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(Player)
	local IsFriend = Player:IsFriendsWith(UserId)
	print('You are currently ' .. (IsFriend and '' or 'NOT') .. ' friends with this player.')
end)
1 Like

Compact-er version:

game.Players.PlayerAdded:Connect(function(plr)
    print("You\'re ".. (plr:IsFriendsWith(Id) and '' or 'not') .. " friends with this user")
end)
-- woops thanks for catching my error @Syclya

I prefer locals as they are faster when accessed the 2nd time, and further.
This is only an example after all, you did not need to comment.

Also, NOT is invalid as it is not a string, it does not lead to anything and will error.

2 Likes