Grid system help

Hello so I’ve trying to make a grid system but I have a collision problem this is the hitbox script

Video: robloxapp-20240716-0723441.wmv (3.7 MB)

-- Checks for collisions on the hitbox
local function checkHitbox()
	if not (hitbox:IsDescendantOf(workspace) and collisions) then return end
	if range then setCurrentState(5) else setCurrentState(1) end
	character = player.Character
	
	local hitboxdifference = 0.001
	
	hitbox.CanCollide = false
	hitbox.Name = "Hitbox0"
	
	if hitbox.Parent:FindFirstChild("Hitbox") then
		hitbox.Parent.Hitbox.CanCollide = false
	end
	
	if hitbox.Parent:FindFirstChild("NewPrimaryPart") then
		hitbox.Parent.NewPrimaryPart.CanCollide = false
	end
	
	local collisionPoints: {BasePart} = workspace:GetPartBoundsInBox(hitbox.CFrame,hitbox.Size-Vector3.new(hitboxdifference,hitboxdifference,hitboxdifference))

	-- Checks if there is collision on any object that is not a child of the object and is not a child of the player
	for i: number = 1, #collisionPoints, 1 do
		if not collisionPoints[i].CanTouch then continue end
		if (not charCollisions and collisionPoints[i]:IsDescendantOf(character)) then continue end
		if not ((not collisionPoints[i]:IsDescendantOf(object)) and collisionPoints[i] ~= plot) then continue end
		
		setCurrentState(3)
		if preferSignals then collided:Fire(collisionPoints[i]) end; break
	end

	return
end

and this is the grid script

local function calculateItemLocation(last: any, final: boolean): CFrame
    local output
    
    -- Convert last to CFrame if it's a Vector3
    if typeof(last) == "Vector3" then
        output = CFrame.new(last)
    elseif typeof(last) == "CFrame" then
        output = last
    else
        error("Invalid argument #1 (CFrame or Vector3 expected)")
    end
    
    -- Example transformation based on the `final` parameter
    if final then
        -- Apply rotation and translation if final is true
        output = output * CFrame.new(10, 20, 30) * CFrame.Angles(math.rad(45), math.rad(30), math.rad(15))
    else
        -- Apply a different transformation if final is false
        output = output * CFrame.new(-10, -20, -30) * CFrame.Angles(math.rad(-45), math.rad(-30), math.rad(-15))
    end

    return output
end