Can't figure out how to lay out this code

So I’m making something and it needs to check if the part is being touched or not. But this is already in a function so idk how i would do it.

So basically, on the server event, it checks if a part is touching a ore, and then if it is true (as well as a cooldown thing). If the ore exists or not will be a boolean in possibleOre. I’ve got no idea how to do this inside of another function (if i even have to do it in said function).
Here is the code for the server script in the tool

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local events = ReplicatedStorage.Events
local mineOre = events.MineOre
local oreMined = events.OreMined
local cooldown = {}
local touchpart = script.Parent.a


mineOre.OnServerEvent:Connect(function(player)
	if cooldown[player] ~= true and possibleOre then
		cooldown[player] = true

		local character = player.Character
		local humanoidRootPart = character.HumanoidRootPart

			
		if CollectionService:HasTag(possibleOre, "Ore") then
			local oreData = possibleOre.OreData
			local oreHealth = oreData.CurrentHealth
			local mineOreSound = oreData.MineOre
			mineOreSound:Play()

			oreHealth.Value -= 1

			mineOreSound.Ended:Connect(function()
			if oreHealth.Value <= 0 then
				mineOreSound:Play()
				oreMined:Fire(possibleOre)
				end
			end)
		end
		task.wait(1.5)
		cooldown[player] = nil
	end
end)

You can check if it is touching something by doing either;
a) WorldRoot:GetPartsInPart() | Roblox Creator Documentation
b) BasePart:GetTouchingParts() | Roblox Creator Documentation