Script doing some really wacky stuff with .Touched()

So I got a message from someone that was referred to be from an old friend I used to help out and he has a gear script. It essentialy waits for the Handle to be touched.

It starts off as

local Nub = script.Parent

local Handle = Nub.Handle

and towards the end of the script, after initialising the onTouched function to do the stuff he wants, it goes
Handle.Touched:connect(onTouched)

If I put something like print(Nub) and print(Nub.Parent) it returns the Handle and the tool’s name “Nub”; this script is situated within the handle.

However, everytime the tool is used, it spawns the little head like the other script is supposed to, which then activates the onTouched function, but it then returns “Handle is not a valid member of Part” at line 2. This is odd, as I already defined Handle and the script has ALREADY recognised this. Quite honestly I have no clue why this is doing such a thing. Does anyone have any idea why this is happening?

Now, I took this on thinking it was some typo or something, but I am actually quite confused; I’m not new to scripting and I’ve been doing it for many years, but this is just- odd? Not sure if I’ve just had a really long day and I’m not in the right mind set, but I don’t understand why this is happening, quite honestly.

Can you send the complete code?? As well with a picture of the hierarchy of the tool?

Sure, I wasn’t sure if he’d want it sent over, but I’ve got his permission n all

Don’t mean to dump the entire script on you, but here it is:

local Handle = Nub.Handle

local touched = false

function onTouched(part)

	if touched then
		return
	end

	touched = true

	local humanoid = part.Parent:FindFirstChild("Humanoid")
	local Head = part.Parent:FindFirstChild("Head")
	local LArm = part.Parent:FindFirstChild("Left Arm")
	local LLeg = part.Parent:FindFirstChild("Left Leg")
	local RArm = part.Parent:FindFirstChild("Right Arm")
	local RLeg = part.Parent:FindFirstChild("Right Leg")
	local Torso = part.Parent:FindFirstChild("Torso")
	local x = {'Plastic','ForceField','Neon','Glass','Metal','Wood','Grass','Slate','Concrete','WoodPlanks','Cobblestone','CorrodedMetal','DiamondPlate','Foil','Ice','Brick','Sand','Fabric','Granite','Marble','Pebble'}
	local h = {'Ball','Block','Cylinder'}

	if humanoid ~= nil then

		if Head:FindFirstChild("Mesh") then
			Head = Head.Mesh:remove('Mesh')
		end
		Nub.SlipSound:Play()
		humanoid.Jump = true
		humanoid.PlatformStand = true
		humanoid.Sit = true
		Head.BrickColor = BrickColor.Random()
		LArm.BrickColor = BrickColor.Random()
		LLeg.BrickColor = BrickColor.Random()
		RArm.BrickColor = BrickColor.Random()
		RLeg.BrickColor = BrickColor.Random()
		Torso.BrickColor = BrickColor.Random()
		Head.Material  = (x[math.random(1, #x)])
		LArm.Material  = (x[math.random(1, #x)])
		LLeg.Material  = (x[math.random(1, #x)])
		RArm.Material  = (x[math.random(1, #x)])
		RLeg.Material  = (x[math.random(1, #x)])
		Torso.Material  = (x[math.random(1, #x)])
		Head.Shape  = (h[math.random(1, #h)])
		LArm.Shape  = (h[math.random(1, #h)])
		LLeg.Shape  = (h[math.random(1, #h)])
		RArm.Shape  = (h[math.random(1, #h)])
		RLeg.Shape  = (h[math.random(1, #h)])
		Torso.Shape  = (h[math.random(1, #h)])
		wait(.01)
		humanoid.PlatformStand = false
	end

	touched = false

end

Handle.Touched:connect(onTouched)

Furtherly, here’s the hierachy:

I’m not totally sure, but maybe what happened is, handle is no longer a child of nub, are you reparenting it or something

no, nothing like that, it’s just a standard tool, I really have zero clue why this is happening

local Nub = script.Parent.Parent

n…no it’s not? It’s parented to the Nub tool here? Could this be the problem?