Checking players friends

Hi!
I’m trying to script a script that checks if two players that are NOT in-game are friends.

I tried to use IsFriendsWith, but that needs one of the players to be in-game.

Is there a way to do it?

This script is used to check votes on a voting center, and I want it to check if the player who voted a user and the user voted are friends.

The names of the players are stored on this String Values that are located on the vote frame image

--The username are inserted when the frame is duplicated
	for i,v in pairs(tab) do
		local frame = game.StarterGui.Main.Main.Votes.ScrollingFrame.Frame2:Clone()
		frame.Name = i
		frame.Visible = true
		local voted = frame.Voted
		local player = frame.Player.TextLabel
		frame.Parent = game.StarterGui.Main.Main.Votes.ScrollingFrame
		voted.Text = "Voted for "..v
		frame.VotedVal.Value = v --Here
		frame.PlayerVal.Value = i --Here
		player.Text = i
	end

--And the player user Id is requested with a function on a local script located on each frame

function getUserIdFromUsername(name)
	if cache[name] then return cache[name] end
	local id
	pcall(function ()
		id = Players:GetUserIdFromNameAsync(name)
	end)
	cache[name] = id
	return id
end

--That I use for getting the player's decal at the moment
while wait(1) do
	script.Parent.Photo.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. getUserIdFromUsername(script.Parent.PlayerVal.Value) .."&width=420&height=420&format=png"
end

Did you try looking into the Friends API?

1 Like