Attempt to index nil with 'IsFriendsWith'

I have this code

local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
//some code
if plr:IsFriendsWith(owner.UserId) then
//more code

And it all works but I get the error attempt to index nil with 'IsFriendsWith'

1 Like

Does your code currently have any way to handle situations in which if game.Players:GetPlayerFromCharacter(hit.Parent) returns nil that it won’t try to run plr:IsFriendsWith(owner.UserId)?

Can you show the context of that code?

I forgot to add this, and I did: its fixed

1 Like