Why wont this script destroy the Advancement Grimoire?

  1. What do you want to achieve? a script that destroys the tool once the proximity prompt is triggered

  2. What is the issue? its giving me an error saying that I’m attempting to index nil with ‘Destroy’

  3. What solutions have you tried so far? none so far because I didn’t find anything similar to my problem

here’s the code so far, all help is appreciated

-- variables

local proximityPrompt = script.Parent.ProximityPrompt

-- code

	player.Team = game:GetService("Teams").Acolyte
	player.Backpack:FindFirstChild("Advancement Grimoire"):Destroy()

You are assuming that FindFirstChild will return a non-nil value, but it sometimes returns nil.
There are 2 things you can do:
Check that you didn’t make a typo in the name
Do something like this:

local advancementGrimoire = player.Backpack:FindFirstChild("Advancement Grimoire")
if advancementGrimoire then
1 Like