"No FriendService" error

Hi developers! I am recieving this error when using Player:IsFriendsWith

Error:

No FriendService

No documentation on wiki mentions this error, and it’s detrimental to my game, as I want to teleport players that aren’t friends with the “Server owner”

This is the code creating the error here:

if not ServerOwner.Value:IsFriendsWith(Player.UserId) then

The ServerOwner is a ObjectValue containing the first player that joins the server, and all preceding players go through this check to ensure they are friends with the server owner, if they aren’t, they go to their own server. Any clues on how I can get rid of this error? FriendService seems to be a service used internally from Roblox


Solutions tried:

  • Adding a GetService(‘FriendService’) at the top of my code

Are you doing this from ReplicatedFirst?

No, doing this from server side in a PlayerAdded event

This error happens because the Player object you are calling :IsFriendsWith on has left the server. You should instead use Player:IsFriendsWith(ServerOwner.Value.UserId), or preferably just store the UserId of the first player who joined the server instead of their player object.

5 Likes

Thanks! I would assume that a player that has left the game, with a reference from the ObjectValue, would still be able to have this function called on it, perhaps a wiki clarification?

Solved the problem, nethertheless! :+1:

edit: seems wiki is broken for that page anyway,

“If a player leaves a group while they are in the game, it will still think they’re in that group until they leave. However, this does not happen when used with a LocalScript.”

Doesn’t seem related to checking if someone is friends with someone.