How do i subtract a value when a players friend leaves

i cant think of anything of how to do this and dont know where to look for the

game.Players.PlayerRemoving:Connect(function(player)
	local friends = player:IsFriendsWith(game.Players.LocalPlayer.UserId)

	if friends then
		friendCount -= 1
		NumberOfFriendsInGame.Text = "Friends: "..friendCount
	end
end)

Hello!

https://devforum.roblox.com/t/no-friendservice-error/299444

1 Like

This error occurs because :IsFriendWith doesn’t work on a player that isn’t in-game anymore. Instead, you could try and do it vice-versa by getting checking if you are friends with the person who left.

game.Players.PlayerRemoving:Connect(function(player)
	local friends = game.Players.LocalPlayer:IsFriendsWith(player.UserId)
	if friends then
		... do the rest here
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.