IsFriendsWith() not working under no circumstances

I’m making a party system that allows the owner to toggle if it’s friends only or not. Seems simple right?

Well, I’m using the function game.Players.LocalPlayer:IsFriendsWith() but it just never works no matter what I do.

I’ve already checked out DevForum posts about this same issue and their solutions never work for me.

Here’s the important code:

if FriendsOnly.Value and game.Players.LocalPlayer:IsFriendsWith(game.Players[PartyOwner].UserId) then
	JoinParty()	
elseif not FriendsOnly.Value then
	JoinParty()
end

FriendsOnly is a boolean that represents if a party is set to friends only or not.

The PartyOwner variable represents this: local PartyOwner = script.Parent.Parent.Name:split("-")[1]
Basically the Party frame is named the Owner’s Name then the Party Number (such as, the 4th party created by XXXTMS would be “XXXTMS-4”)
It’s set in string form (as shown by :split())

2 Likes

Try printing game.Players[PartyOwner]. Does it return nil, or does it correctly return the party owner? Also, confirm that FriendsOnly.Value is true.

1 Like

You are using game.Players.LocalPlayer, so I assume this code is running within the context of a LocalScript. According to official documentation, :IsFriendsWith() only runs on the server, and can’t run on the client.

1 Like

Sooo both of your replies were helpful, I wasn’t even setting the FriendsOnly property when the party was created, but I also needed to use a ServerScript for it to work.

Thanks for the help! Although, I don’t know who I should give the solution to.