How do I make a touching function?

So should I increase the 20 or something?

The capture point is a cube so there is no middle. I just want to detect if the player is inside the cube standing still or walking.

Using a cool approach from this stackoverflow post, we can determine whether a point is within a part.

In the stackoverflow post, it calculates the cube3d_center, which we don’t need as Roblox already has the BasePart.Position property.

Also, this works based on the diagonals of the part, so using any valid combination of points should work. I believe the implementation here should work:

function CheckIfPointInPart(point, part)
    local size = part.Size * 0.5
    local partCFrame = part.CFrame
    
    local b1 = partCFrame * size * Vector3.new(1, -1, -1)
    local b2 = partCFrame * -size
    local b3 = partCFrame * size * Vector3.new(-1, -1, 1)
    local t1 = partCFrame * size * Vector3.new(1, 1, -1)
    
    point = CFrame.new(part.Position):VectorToObjectSpace(point)
    
    local dir1 = (b1 - b2)
    local size1 = dir1.Magnitude
    dir1 = dir1 / size1
    
    local dir2 = (b3 - b2)
    local size2 = dir2.Magnitude
    dir2 = dir2 / size2

    local dir3 = (t1 - b1)
    local size3 = dir3.Magnitude
    dir3 = dir3 / size3
    
    local dirVec = point - part.Position
    
    validX = dirVec:Dot(dir1) * 2 <= size1
    validY = dirVec:Dot(dir2) * 2 <= size2
    validZ = dirVec:Dot(dir3) * 2 <= size3
    
    insidePart = validX and validY and validZ
    return insidePart
end

The way you would use it in your game is:

while wait() do
 if CheckIfPointInPart(Character.HumanoidRootPart.Position, CapturePoint) then
  -- Inside Capture Point
 end
end

Hope this works for what you want, keep me posted!