Making an NPC collect cash + updating ScreenGUI

Hi, first post on the forum.
I’m making a Raise A Floppa type game, and I’ve been trying for the past few months to implement an auto cash collection system. However, I have tried unsuccessfully to do so.
One suggestion I have used so far is to test if the NPC is successfully collecting the cash and updating the GUI as planned (printing out a phrase). If not, it’ll either not display the phrase or simply error out.


I have tried the following: Adding an ‘or’ clause (complete with a FindFirstChild + WaitForChild local bit), modifying the code in a way to try and have the NPC update the GUI, all of that.
NOTE: I’m trying to make this character a little like Bingus in RAF, where collecting cash is done for you.

local players = game:GetService("Players")
local ghostbux = script.Parent

function debounce(func)
	local isRun = false
	return function(hit)
		if not isRun then
			isRun = true
			func(hit)
			isRun = false
		end
	end
end


ghostbux.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		if not character:FindFirstChild("notPlayer") then
			local player = players:GetPlayerFromCharacter(character)
			if player then
				local leaderstats = player.leaderstats
				print("beep bop") -- The phrase that prints when a player (or when successful the npc) collects the cash
			local ghostbux = leaderstats.GhostBux
				ghostbux.Value = ghostbux.Value + 1
		end
		ghostbux:Destroy()
	end
	end
end)```


-- Here's the code in my cash part. I've modified this code a bit in the past, but reverted changes.
-- This has bugged me for a while, so I may need help with modifying the code. Or do I just scrap it altogether and just instead rewrite the whole cash system?