Attempt to Index nil with FindFirstChild

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to find the Folder Informations in the player character. The script is a basic script, not local, not module.

  2. What is the issue? Include screenshots / videos if possible!
    The following script can’t find the Character into the player. Making it impossible to find the folder. I will link the error i get too.

local function OnPlayerRemoved(player)
	local Character = player:FindFirstChild("Character")
	local Folder = Character:FindFirstChild("Informations")

Error I get: attempt to index nil with 'FindFirstChild’

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried searching around the web for a solution, sadly found nothing.

Usually when a player leaves their character is deleted shortly after, thus when you fire the OnPlayerRemoved function and search for a character there is none. But the problem with your code is the character isn’t actually a child of the player. What you want to achieve would be:

local Character = player.Character
1 Like

I thought the character would get removed when it finished the code in the function. Thanks for letting me know that.

1 Like

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