I'm trying to make a game based off of spongebob, and one of the features in the game is where you can make a krabby patty and serve it to someone. Everything works fine except for this small detail: The fact it gets removed from the players inventory after being served and it gives the player money. The way it works is you cook the krabby patty, then you touch an NPCs torso with it, then it'll trigger a BindableEvent. The bindable event works fine but I keep getting this error in the output: "Players.RealDipperBot.Backpack.RawPatty.Top Bun.MoneyGiver:5: attempt to index local 'player' (a nil value)". And last but not least here's the script:

local BindableEvent = game.Workspace:WaitForChild("BindableEvent")


BindableEvent.Event:Connect(function(player)
	if player:FindFirstChild("leaderstats") then
	player.leaderstats.Dollars.Value = player.leaderstats.Dollars.Value + 10
	wait(0.1)
	script.Parent:remove()
	end
end)